Browse Source

Correctly handle export/import generation depending on whether we're compiling for a system that needs indirect imports or not.

systems.pas:
  * replace systems_package_need_exports with systems_indirect_var_imports
pmodules.pas, proc_package:
  - remove check for systems_package_need_exports
pkgutil.pas:
  * insert_export, export_unit: export the direct or the indirect variable symbol depending on systems_indirect_var_imports

git-svn-id: branches/svenbarth/packages@32451 -
svenbarth 9 years ago
parent
commit
d4279fac24
3 changed files with 17 additions and 6 deletions
  1. 14 3
      compiler/pkgutil.pas
  2. 1 1
      compiler/pmodules.pas
  3. 2 2
      compiler/systems.pas

+ 14 - 3
compiler/pkgutil.pas

@@ -154,7 +154,7 @@ implementation
                   if (def.typ=objectdef) and (oo_has_vmt in tobjectdef(def).objectoptions) then
                     begin
                       hp:=texported_item.create;
-                      hp.name:=stringdup(tobjectdef(def).vmt_mangledname);
+                      hp.name:=stringdup(tobjectdef(def).vmt_mangledname(not (target_info.system in systems_indirect_var_imports)));
                       hp.options:=hp.options+[eo_name];
                       exportlib.exportvar(hp);
                     end;
@@ -169,7 +169,10 @@ implementation
           begin
             if publiconly and not (vo_is_public in tstaticvarsym(sym).varoptions) then
               exit;
-            varexport(tsym(sym).mangledname);
+            if target_info.system in systems_indirect_var_imports then
+              varexport(tsym(sym).mangledname)
+            else
+              varexport(tsym(sym).mangledname+indirect_suffix);
           end;
         else
           begin
@@ -182,7 +185,13 @@ implementation
   procedure export_unit(u: tmodule);
     var
       i : longint;
+      isindirect : boolean;
     begin
+      { For targets that need indirect variable exports we export the direct symbol
+        and an indirect symbol will be generated in the consuming library/program.
+        On systems that don't have indirect exports we directly export only the
+        indirect symbols }
+
       u.globalsymtable.symlist.ForEachCall(@insert_export,u.globalsymtable);
       { check localsymtable for exports too to get public symbols }
       u.localsymtable.symlist.ForEachCall(@insert_export,u.localsymtable);
@@ -196,7 +205,9 @@ implementation
                 procexport(name);
               AT_DATA:
                 begin
-                  if pos(indirect_suffix,name)=length(name)-length(indirect_suffix)+1 then
+                  isindirect := pos(indirect_suffix,name)=length(name)-length(indirect_suffix)+1;
+                  if (isindirect and (target_info.system in systems_indirect_var_imports)) or
+                      (not isindirect and not (target_info.system in systems_indirect_var_imports)) then
                     continue;
                   varexport(name);
                 end;

+ 1 - 1
compiler/pmodules.pas

@@ -1586,7 +1586,7 @@ type
                  systemunit:=tglobalsymtable(uu.u.globalsymtable);
                  load_intern_types;
                end;
-             if not assigned(uu.u.package) and (target_info.system in systems_packages_need_exports) then
+             if not assigned(uu.u.package) then
                export_unit(uu.u);
 
              uu:=tused_unit(uu.next);

+ 2 - 2
compiler/systems.pas

@@ -298,8 +298,8 @@ interface
                                          system_x86_64_win64,
                                          system_ia64_win64]+systems_linux+systems_android;
 
-       { all systems that require exports for packages }
-       systems_packages_need_exports = [system_i386_nativent]+systems_windows;
+       { all systems that have indirect variable imports }
+       systems_indirect_var_imports = [system_i386_nativent]+systems_windows;
 
        { all systems for which weak linking has been tested/is supported }
        systems_weak_linking = systems_darwin + systems_solaris + systems_linux + systems_android;