Repository navigation
Closed
Labels
Description
I did try to use StaticICULinking on Alpine to make Docker from scratch more interesting
I add clang libexecinfo binutils musl-dev build-base zlib-static cmake icu-static icu-dev dependencies. Basically just add cmake icu-static icu-dev as additional packages.
Add following changes
<PropertyGroup>
<InvariantGlobalization>false</InvariantGlobalization>
<StaticICULinking>true</StaticICULinking>
</PropertyGroup>
<ItemGroup>
<LinkerArg Include="-static" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="8.0.0-alpha.1.22609.9" />
</ItemGroup>And build fails with following LOOONG error message which I trim in preview, but attach as file
#13 13.35 /root/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.0-alpha.1.22609.9/build/Microsoft.DotNet.ILCompiler.SingleEntry.targets(45,5): warning : Delete explicit 'Microsoft.DotNet.ILCompiler' package reference in your project file. Explicit 'Microsoft.DotNet.ILCompiler' package reference can run into version errors. [/app/HelloWorldStatic.csproj]
#13 13.97 -- The C compiler identification is GNU 11.2.1
#13 13.99 -- Detecting C compiler ABI info
#13 14.11 -- Detecting C compiler ABI info - done
#13 14.14 -- Check for working C compiler: /usr/bin/cc - skipped
#13 14.14 -- Detecting C compile features
#13 14.14 -- Detecting C compile features - done
#13 14.15 -- Performing Test HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS
#13 14.38 -- Performing Test HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS - Success
#13 14.38 -- Looking for ucol_setMaxVariable
#13 14.68 -- Looking for ucol_setMaxVariable - found
#13 14.68 -- Looking for ucol_clone
#13 14.83 -- Looking for ucol_clone - found
#13 14.87 CMake Warning (dev) in CMakeLists.txt:
#13 14.87 No cmake_minimum_required command is present. A line of code such as
#13 14.87
#13 14.87 cmake_minimum_required(VERSION 3.23)
#13 14.87
#13 14.87 should be added at the top of the file. The version specified may be lower
#13 14.87 if you wish to support older CMake versions for this project. For more
#13 14.87 information run "cmake --help-policy CMP0000".
#13 14.87 This warning is for project developers. Use -Wno-dev to suppress it.
#13 14.87
#13 14.87 -- Configuring done
#13 14.87 -- Generating done
#13 14.87 -- Build files have been written to: /app/obj/Release/net7.0/linux-musl-x64/libs/System.Globalization.Native/build
#13 14.89 [ 8%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_calendarData.o
#13 14.90 [ 25%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_casing.o
#13 14.90 [ 25%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_idna.o
#13 14.90 [ 33%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_localeNumberData.o
#13 14.90 [ 50%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_locale.o
#13 14.90 [ 50%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_localeStringData.o
#13 14.90 [ 58%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_collation.o
#13 14.91 [ 66%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_normalization.o
#13 14.91 [ 75%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_icushim_static.o
#13 14.92 [ 83%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/pal_timeZoneInfo.o
#13 14.93 [ 91%] Building C object CMakeFiles/System.Globalization.Native-Static.dir/entrypoints.o
#13 15.26 /root/.nuget/packages/runtime.linux-musl-x64.microsoft.dotnet.ilcompiler/8.0.0-alpha.1.22609.9/native/src/libs/System.Globalization.Native/pal_collation.c: In function 'CloneCollatorWithOptions':
#13 15.26 /root/.nuget/packages/runtime.linux-musl-x64.microsoft.dotnet.ilcompiler/8.0.0-alpha.1.22609.9/native/src/libs/System.Globalization.Native/pal_collation.c(338,9): warning G46159011: 'ucol_safeClone_71' is deprecated [-Wdeprecated-declarations] [/app/HelloWorldStatic.csproj]
#13 15.26 338 | pClonedCollator = ucol_safeClone(pCollator, NULL, NULL, pErr);
#13 15.26 | ^~~~~~~~~~~~~~~
#13 15.26 In file included from /usr/include/unicode/platform.h:25,
#13 15.26 from /usr/include/unicode/ptypes.h:52,
#13 15.26 from /usr/include/unicode/umachine.h:46,
#13 15.26 from /usr/include/unicode/utypes.h:38,
#13 15.26 from /usr/include/unicode/ucurr.h:12,
#13 15.26 from /root/.nuget/packages/runtime.linux-musl-x64.microsoft.dotnet.ilcompiler/8.0.0-alpha.1.22609.9/native/src/libs/System.Globalization.Native/pal_icushim_internal.h:24,
#13 15.26 from /root/.nuget/packages/runtime.linux-musl-x64.microsoft.dotnet.ilcompiler/8.0.0-alpha.1.22609.9/native/src/libs/System.Globalization.Native/pal_errors_internal.h:6,
#13 15.26 from /root/.nuget/packages/runtime.linux-musl-x64.microsoft.dotnet.ilcompiler/8.0.0-alpha.1.22609.9/native/src/libs/System.Globalization.Native/pal_collation.c:11:
#13 15.26 /usr/include/unicode/ucol.h:1350:1: note: declared here
#13 15.26 1350 | ucol_safeClone(const UCollator *coll,
#13 15.26 | ^~~~~~~~~~~~~~
#13 15.55 /root/.nuget/packages/runtime.linux-musl-x64.microsoft.dotnet.ilcompiler/8.0.0-alpha.1.22609.9/native/src/libs/System.Globalization.Native/pal_collation.c: At top level:
#13 15.55 cc1: note: unrecognized command-line option '-Wno-unknown-warning-option' may have been intended to silence earlier diagnostics
#13 15.55 cc1: note: unrecognized command-line option '-Wno-extra-semi-stmt' may have been intended to silence earlier diagnostics
#13 15.55 cc1: note: unrecognized command-line option '-Wno-documentation-unknown-command' may have been intended to silence earlier diagnostics
#13 15.55 cc1: note: unrecognized command-line option '-Wno-documentation' may have been intended to silence earlier diagnostics
#13 15.55 cc1: note: unrecognized command-line option '-Wno-reserved-id-macro' may have been intended to silence earlier diagnostics
#13 15.55 cc1: note: unrecognized command-line option '-Wno-covered-switch-default' may have been intended to silence earlier diagnostics
#13 15.60 [100%] Linking C static library libSystem.Globalization.Native.a
#13 15.63 [100%] Built target System.Globalization.Native-Static
#13 15.67 Generating native code
#13 22.18 clang-13 : warning : argument unused during compilation: '-pie' [-Wunused-command-line-argument] [/app/HelloWorldStatic.csproj]
#13 22.35 /usr/bin/ld: attempted static link of dynamic object `/usr/bin/../lib/libc.so'
#13 22.72 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao): in function `icu_71::number::impl::MixedUnitLongNameHandler::forMeasureUnit(icu_71::Locale const&, icu_71::MeasureUnit const&, UNumberUnitWidth const&, char const*, icu_71::PluralRules const*, icu_71::number::impl::MicroPropsGenerator const*, icu_71::number::impl::MixedUnitLongNameHandler*, UErrorCode&)':
#13 22.72 number_longnames.cpp:(.text+0x2137): undefined reference to `__cxa_throw_bad_array_new_length'
#13 22.72 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao): in function `icu_71::number::impl::MixedUnitLongNameHandler::getMixedUnitModifier(icu_71::number::impl::DecimalQuantity&, icu_71::number::impl::MicroProps&, UErrorCode&) const':
#13 22.72 number_longnames.cpp:(.text+0x2918): undefined reference to `__cxa_throw_bad_array_new_length'
#13 22.72 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao): in function `icu_71::number::impl::LongNameMultiplexer::forMeasureUnits(icu_71::Locale const&, icu_71::MaybeStackVector<icu_71::MeasureUnit, 8> const&, UNumberUnitWidth const&, char const*, icu_71::PluralRules const*, icu_71::number::impl::MicroPropsGenerator const*, UErrorCode&)':
#13 22.72 number_longnames.cpp:(.text+0x4afe): undefined reference to `__cxa_throw_bad_array_new_length'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao):(.data.rel.ro._ZTIN6icu_716number4impl15LongNameHandlerE[_ZTIN6icu_716number4impl15LongNameHandlerE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao):(.data.rel.ro._ZTIN6icu_716number4impl24MixedUnitLongNameHandlerE[_ZTIN6icu_716number4impl24MixedUnitLongNameHandlerE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao):(.data.rel.ro._ZTIN6icu_716number4impl19LongNameMultiplexerE[_ZTIN6icu_716number4impl19LongNameMultiplexerE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_longnames.ao):(.data.rel.ro+0x18): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao): in function `icu_71::number::impl::ConstantMultiFieldModifier::semanticallyEquivalent(icu_71::number::impl::Modifier const&) const':
#13 22.73 number_modifiers.cpp:(.text+0x2b8): undefined reference to `__dynamic_cast'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao): in function `icu_71::number::impl::ConstantAffixModifier::semanticallyEquivalent(icu_71::number::impl::Modifier const&) const':
#13 22.73 number_modifiers.cpp:(.text+0x33e): undefined reference to `__dynamic_cast'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao): in function `icu_71::number::impl::SimpleModifier::semanticallyEquivalent(icu_71::number::impl::Modifier const&) const':
#13 22.73 number_modifiers.cpp:(.text+0x3ac): undefined reference to `__dynamic_cast'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao):(.data.rel.ro._ZTIN6icu_716number4impl8ModifierE[_ZTIN6icu_716number4impl8ModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao):(.data.rel.ro._ZTIN6icu_716number4impl13ModifierStoreE[_ZTIN6icu_716number4impl13ModifierStoreE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao):(.data.rel.ro._ZTIN6icu_716number4impl21ConstantAffixModifierE[_ZTIN6icu_716number4impl21ConstantAffixModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao):(.data.rel.ro._ZTIN6icu_716number4impl14SimpleModifierE[_ZTIN6icu_716number4impl14SimpleModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao):(.data.rel.ro._ZTIN6icu_716number4impl26ConstantMultiFieldModifierE[_ZTIN6icu_716number4impl26ConstantMultiFieldModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao):(.data.rel.ro._ZTIN6icu_716number4impl30CurrencySpacingEnabledModifierE[_ZTIN6icu_716number4impl30CurrencySpacingEnabledModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_modifiers.ao):(.data.rel.ro._ZTIN6icu_716number4impl21AdoptingModifierStoreE[_ZTIN6icu_716number4impl21AdoptingModifierStoreE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_patternmodifier.ao):(.data.rel.ro._ZTIN6icu_716number4impl20AffixPatternProviderE[_ZTIN6icu_716number4impl20AffixPatternProviderE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_patternmodifier.ao):(.data.rel.ro._ZTIN6icu_716number4impl24ImmutablePatternModifierE[_ZTIN6icu_716number4impl24ImmutablePatternModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_patternmodifier.ao):(.data.rel.ro._ZTIN6icu_716number4impl22MutablePatternModifierE[_ZTIN6icu_716number4impl22MutablePatternModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_scientific.ao): in function `icu_71::number::impl::ScientificModifier::semanticallyEquivalent(icu_71::number::impl::Modifier const&) const':
#13 22.73 number_scientific.cpp:(.text+0x5e): undefined reference to `__dynamic_cast'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_scientific.ao):(.data.rel.ro._ZTIN6icu_716number4impl18ScientificModifierE[_ZTIN6icu_716number4impl18ScientificModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(number_scientific.ao):(.data.rel.ro._ZTIN6icu_716number4impl17ScientificHandlerE[_ZTIN6icu_716number4impl17ScientificHandlerE]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
#13 22.73 /usr/bin/ld: /usr/bin/../lib/libicuuc.a(ustr_titlecase_brkiter.ao):(.data.rel.ro._ZTIN6icu_7124WholeStringBreakIteratorE[_ZTIN6icu_7124WholeStringBreakIteratorE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.79 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationbuilder.ao):(.data.rel.ro._ZTIN6icu_7116CollationBuilderE[_ZTIN6icu_7116CollationBuilderE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.79 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationbuilder.ao):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.79 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationbuilder.ao):(.data.rel.ro._ZTIN6icu_7111CEFinalizerE[_ZTIN6icu_7111CEFinalizerE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.79 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationbuilder.ao):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
#13 22.79 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationdatabuilder.ao):(.data.rel.ro._ZTIN6icu_7120CollationDataBuilder10CEModifierE[_ZTIN6icu_7120CollationDataBuilder10CEModifierE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.79 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationdatabuilder.ao):(.data.rel.ro._ZTIN6icu_7120CollationDataBuilderE[_ZTIN6icu_7120CollationDataBuilderE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.79 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationdatabuilder.ao):(.data.rel.ro._ZTIN6icu_7128DataBuilderCollationIteratorE[_ZTIN6icu_7128DataBuilderCollationIteratorE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationfastlatinbuilder.ao):(.data.rel.ro._ZTIN6icu_7125CollationFastLatinBuilderE[_ZTIN6icu_7125CollationFastLatinBuilderE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationiterator.ao):(.data.rel.ro._ZTIN6icu_7117CollationIteratorE[_ZTIN6icu_7117CollationIteratorE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(collationruleparser.ao):(.data.rel.ro._ZTIN6icu_7119CollationRuleParser4SinkE[_ZTIN6icu_7119CollationRuleParser4SinkE]+0x0): more undefined references to `vtable for __cxxabiv1::__si_class_type_info' follow
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(ucal.ao): in function `ucal_getDSTSavings_71':
#13 22.80 ucal.cpp:(.text+0x31f): undefined reference to `__dynamic_cast'
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(ucal.ao): in function `ucal_setGregorianChange_71':
#13 22.80 ucal.cpp:(.text+0x51a): undefined reference to `__dynamic_cast'
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(ucal.ao): in function `ucal_getGregorianChange_71':
#13 22.80 ucal.cpp:(.text+0x59a): undefined reference to `__dynamic_cast'
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(ucal.ao): in function `ucal_getTimeZoneOffsetFromLocal_71':
#13 22.80 ucal.cpp:(.text+0xdf5): undefined reference to `__dynamic_cast'
#13 22.80 /usr/bin/ld: /usr/bin/../lib/libicui18n.a(ucal.ao): in function `ucal_getTimeZoneTransitionDate_71':
#13 22.80 ucal.cpp:
(.text+0x1252): undefined reference to `__dynamic_cast'
Any ideas what am I missing?
Activity
am11 commentedon Dec 12, 2022
We ended up supporting it via property:
StaticExecutable=true/false(similar toNativeLib=Static/Shared):<PropertyGroup> <InvariantGlobalization>false</InvariantGlobalization> <StaticICULinking>true</StaticICULinking> + <StaticExecutable>true</StaticExecutable> </PropertyGroup> - <ItemGroup> - <LinkerArg Include="-static" /> - </ItemGroup>kant2002 commentedon Dec 12, 2022
I suppose I want also System.Security.Cryptography.Native and System.IO.Compression.Native
Is this something that would be welcomed?
jkotas commentedon Dec 12, 2022
Do you still see this warning? It sounds like the auto-detection for
HAVE_UCOL_CLONEdoes not work correctly.jkotas commentedon Dec 12, 2022
Yes!
am11 commentedon Dec 12, 2022
IO.Compressionis fine in statically linked binary; libz is explicitly listed (see-lz) in targets.Security.Cryptographywill need some work. libssl is a soft dependency; loaded at run time with dlopen and we get a run time error:No usable version of libssl was found. Adding-lssl -lcrypto, and installingapk add openssl-libs-staticis not enough, we would need to also change the initialization to skip dlopen calls when libssl is statically linked (similar to 7646e76).IIRC, libnuma (iff available, it's used by GC) is also an optional soft dependency which is loaded with dlopen.