From 2e544bd8de72ae3fbd5b511ac893c9fb3bc37611 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 13 Mar 2010 23:37:20 +0000 Subject: [PATCH] * smartlink dynamic libraries under Mac OS X (mantis #15984) git-svn-id: trunk@15011 - --- compiler/systems/t_bsd.pas | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas index 3f81ab5116..c421d0af48 100644 --- a/compiler/systems/t_bsd.pas +++ b/compiler/systems/t_bsd.pas @@ -166,9 +166,9 @@ begin ExeCmd[1]:='ld $PRTOBJ $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`'; {$endif ndef cpu64bitaddr} if (apptype<>app_bundle) then - DllCmd[1]:='ld $PRTOBJ $OPT -dynamic -dylib -multiply_defined suppress -L. -o $EXE `cat $RES`' + DllCmd[1]:='ld $PRTOBJ $OPT $GCSECTIONS -dynamic -dylib -multiply_defined suppress -L. -o $EXE `cat $RES`' else - DllCmd[1]:='ld $PRTOBJ $OPT -dynamic -bundle -multiply_defined suppress -L. -o $EXE `cat $RES`' + DllCmd[1]:='ld $PRTOBJ $OPT $GCSECTIONS -dynamic -bundle -multiply_defined suppress -L. -o $EXE `cat $RES`' end end else @@ -620,16 +620,26 @@ var cmdstr, extdbgbinstr, extdbgcmdstr : TCmdStr; + GCSectionsStr : string[40]; exportedsyms: text; success : boolean; begin MakeSharedLibrary:=false; + GCSectionsStr:=''; if not(cs_link_nolink in current_settings.globalswitches) then Message1(exec_i_linking,current_module.sharedlibfilename^); { Write used files and libraries } WriteResponseFile(true); + if (cs_link_smart in current_settings.globalswitches) and + (tf_smartlink_sections in target_info.flags) then + if not(target_info.system in systems_darwin) then + { disabled because not tested + GCSectionsStr:='--gc-sections' } + else + GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms'; + InitStr:='-init FPC_LIB_START'; FiniStr:='-fini FPC_LIB_EXIT'; SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename^); @@ -645,6 +655,7 @@ begin Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName)); Replace(cmdstr,'$INIT',InitStr); Replace(cmdstr,'$FINI',FiniStr); + Replace(cmdstr,'$GCSECTIONS',GCSectionsStr); Replace(cmdstr,'$SONAME',SoNameStr); if (target_info.system in systems_darwin) then Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));