Skip to content

Commit

Permalink
Link static libstdc++ with libicuc in NativeAOT (#79501)
Browse files Browse the repository at this point in the history
* Link static libstdc++ with libicuc in NativeAOT

* Address CR feedback

* Improve static related conditions

* Delete default
  • Loading branch information
am11 authored Dec 12, 2022
1 parent 7e10f81 commit 21a8eb5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ The .NET Foundation licenses this file to you under the MIT license.

<ItemGroup>
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
<NativeLibrary Condition="$(NativeLib) == ''" Include="$(IlcSdkPath)libbootstrapper.a" />
<NativeLibrary Condition="$(NativeLib) != ''" Include="$(IlcSdkPath)libbootstrapperdll.a" />
<NativeLibrary Condition="'$(NativeLib)' == ''" Include="$(IlcSdkPath)libbootstrapper.a" />
<NativeLibrary Condition="'$(NativeLib)' != ''" Include="$(IlcSdkPath)libbootstrapperdll.a" />
<NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName).a" />
<NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true'" Include="$(IlcSdkPath)libstdc++compat.a" />
<NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcSdkPath)libstdc++compat.a" />
</ItemGroup>

<ItemGroup>
Expand All @@ -69,10 +69,12 @@ The .NET Foundation licenses this file to you under the MIT license.
<NativeLibrary Include="@(NetCoreAppNativeLibrary->'%(EscapedPath)')" />
</ItemGroup>

<ItemGroup Condition="'$(StaticICULinking)' == 'true'">
<ItemGroup Condition="'$(StaticICULinking)' == 'true' and '$(NativeLib)' != 'Static'">
<NativeLibrary Include="$(IntermediateOutputPath)/libs/System.Globalization.Native/build/libSystem.Globalization.Native.a"/>
<DirectPInvoke Include="libSystem.Globalization.Native" />
<StaticICULibs Include="-Wl,-Bstatic -licuio -licutu -licui18n -licuuc -licudata -Wl,-Bdynamic" />
<StaticICULibs Include="-Wl,-Bstatic" Condition="'$(StaticExecutable)' != 'true'" />
<StaticICULibs Include="-licuio -licutu -licui18n -licuuc -licudata -lstdc++" />
<StaticICULibs Include="-Wl,-Bdynamic" Condition="'$(StaticExecutable)' != 'true'" />
</ItemGroup>

<ItemGroup Condition="'$(TargetOS)' == 'OSX'">
Expand All @@ -86,6 +88,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<Exec Command="$(IlcHostPackagePath)/native/src/libs/System.Globalization.Native/local_build.sh $(IlcHostPackagePath)/ $(IntermediateOutputPath)" Condition="'$(StaticICULinking)' == 'true'"/>

<ItemGroup>
<LinkerArg Include="-static" Condition="'$(StaticExecutable)' == 'true'" />
<LinkerArg Include="@(NativeLibrary)" />
<LinkerArg Include="--sysroot=$(SysRoot)" Condition="'$(SysRoot)' != ''" />
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(TargetOS)' != 'OSX' and '$(TargetTriple)' != ''" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<FullRuntimeName>Runtime.WorkstationGC</FullRuntimeName>
<FullRuntimeName Condition="'$(ServerGarbageCollection)' == 'true' or '$(ControlFlowGuard)' == 'Guard'">Runtime.ServerGC</FullRuntimeName>
<BootstrapperName>bootstrapper</BootstrapperName>
<BootstrapperName Condition="$(NativeLib) != ''">bootstrapperdll</BootstrapperName>
<BootstrapperName Condition="'$(NativeLib)' != ''">bootstrapperdll</BootstrapperName>
<EntryPointSymbol Condition="'$(EntryPointSymbol)' == ''">wmainCRTStartup</EntryPointSymbol>
<LinkerSubsystem Condition="'$(OutputType)' == 'WinExe' and '$(LinkerSubsystem)' == ''">WINDOWS</LinkerSubsystem>
<LinkerSubsystem Condition="'$(OutputType)' == 'Exe' and '$(LinkerSubsystem)' == ''">CONSOLE</LinkerSubsystem>
Expand Down Expand Up @@ -72,7 +72,7 @@ The .NET Foundation licenses this file to you under the MIT license.
</ItemGroup>

<ItemGroup>
<LinkerArg Condition="$(NativeLib) == 'Shared'" Include="/DLL" />
<LinkerArg Condition="'$(NativeLib)' == 'Shared'" Include="/DLL" />
<LinkerArg Include="@(NativeLibrary->'&quot;%(Identity)&quot;')" />
<LinkerArg Include="@(SdkNativeLibrary->'&quot;%(Identity)&quot;')" />
<LinkerArg Include="/NOLOGO /MANIFEST:NO" />
Expand All @@ -81,7 +81,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Include="/INCREMENTAL:NO" />
<LinkerArg Condition="'$(LinkerSubsystem)' != ''" Include="/SUBSYSTEM:$(LinkerSubsystem)" />
<LinkerArg Condition="'$(OutputType)' == 'WinExe' or '$(OutputType)' == 'Exe'" Include="/ENTRY:$(EntryPointSymbol) /NOEXP /NOIMPLIB" />
<LinkerArg Condition="$(NativeLib) == 'Shared'" Include="/INCLUDE:NativeAOT_StaticInitialization" />
<LinkerArg Condition="'$(NativeLib)' == 'Shared'" Include="/INCLUDE:NativeAOT_StaticInitialization" />
<LinkerArg Include="/NATVIS:&quot;$(MSBuildThisFileDirectory)NativeAOT.natvis&quot;" />
<LinkerArg Condition="'$(ControlFlowGuard)' == 'Guard'" Include="/guard:cf" />
</ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ The .NET Foundation licenses this file to you under the MIT license.

<NativeBinaryExt Condition="'$(IsNativeExecutable)' == 'true' and '$(TargetOS)' == 'windows'">.exe</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' == 'true' and '$(TargetOS)' != 'windows'"></NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' == 'windows' and $(NativeLib) == 'Shared'">.dll</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' == 'OSX' and $(NativeLib) == 'Shared'">.dylib</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' != 'windows' and '$(TargetOS)' != 'OSX' and $(NativeLib) == 'Shared'">.so</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' == 'windows' and $(NativeLib) == 'Static'">.lib</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' != 'windows' and $(NativeLib) == 'Static'">.a</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' == 'windows' and '$(NativeLib)' == 'Shared'">.dll</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' == 'OSX' and '$(NativeLib)' == 'Shared'">.dylib</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' != 'windows' and '$(TargetOS)' != 'OSX' and '$(NativeLib)' == 'Shared'">.so</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' == 'windows' and '$(NativeLib)' == 'Static'">.lib</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(TargetOS)' != 'windows' and '$(NativeLib)' == 'Static'">.a</NativeBinaryExt>

<NativeSymbolExt Condition="'$(TargetOS)' == 'OSX'">.dwarf</NativeSymbolExt>
<NativeSymbolExt Condition="'$(TargetOS)' == 'windows'">.pdb</NativeSymbolExt>
Expand All @@ -82,7 +82,7 @@ The .NET Foundation licenses this file to you under the MIT license.

<NativeObject>$(NativeIntermediateOutputPath)$(TargetName)$(NativeObjectExt)</NativeObject>
<NativeBinary>$(NativeOutputPath)$(TargetName)$(NativeBinaryExt)</NativeBinary>
<IlcExportUnmanagedEntrypoints Condition="$(NativeLib) == 'Shared'">true</IlcExportUnmanagedEntrypoints>
<IlcExportUnmanagedEntrypoints Condition="'$(NativeLib)' == 'Shared'">true</IlcExportUnmanagedEntrypoints>
<ExportsFile Condition="$(IlcExportUnmanagedEntrypoints) == 'true' and $(ExportsFile) == ''">$(NativeIntermediateOutputPath)$(TargetName)$(ExportsFileExt)</ExportsFile>

<IlcCompileOutput>$(NativeObject)</IlcCompileOutput>
Expand Down Expand Up @@ -225,7 +225,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<IlcArg Condition="$(IlcGenerateDgmlFile) == 'true'" Include="--scandgmllog:$(NativeIntermediateOutputPath)%(ManagedBinary.Filename).scan.dgml.xml" />
<IlcArg Include="@(RdXmlFile->'--rdxml:%(FullPath)')" />
<IlcArg Include="@(TrimmerRootDescriptor->'--descriptor:%(FullPath)')" />
<IlcArg Condition="$(NativeLib) != ''" Include="--nativelib" />
<IlcArg Condition="'$(NativeLib)' != ''" Include="--nativelib" />
<IlcArg Condition="$(ExportsFile) != ''" Include="--exportsfile:$(ExportsFile)" />
<IlcArg Include="@(AutoInitializedAssemblies->'--initassembly:%(Identity)')" />
<IlcArg Include="@(RuntimeHostConfigurationOption->'--appcontextswitch:%(Identity)=%(Value)')" />
Expand Down

0 comments on commit 21a8eb5

Please sign in to comment.