Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build for FreeBSD arm64 w/NativeAOT #81510

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

sec
Copy link
Contributor

@sec sec commented Feb 1, 2023

Based on 70e1072 this PR adds same things for arm64 host.
With those changes runtime is able to build fine under FreeBSD arm64 host (there is some manual patching required with ObjWriter and UseHardlinksIfPossible property set to false on two targets and BinPlaceUseHardlinksIfPossible=false).

I was using clang14 and needed to pass extra -z nostart-stop-gc to make the build pass for crossgen2 (reading https://lld.llvm.org/ELF/start-stop-gc looks like that change was done starting from 13) - if this should be handled in diffrent way, let me know.

@Thefrank @janvorli @am11

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Feb 1, 2023
@ghost
Copy link

ghost commented Feb 1, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Based on 70e1072 this PR adds same things for arm64 host.
With those changes runtime is able to build fine under FreeBSD arm64 host (there is some manual patching required with ObjWriter and UseHardlinksIfPossible property set to false on two targets and BinPlaceUseHardlinksIfPossible=false).

I was using clang14 and needed to pass extra -z nostart-stop-gc to make the build pass for crossgen2 (reading https://lld.llvm.org/ELF/start-stop-gc looks like that change was done starting from 13) - if this should be handled in diffrent way, let me know.

@Thefrank @janvorli @am11

Author: sec
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@sec sec mentioned this pull request Feb 1, 2023
@Thefrank
Copy link
Contributor

Thefrank commented Feb 1, 2023

FreeBSD x64 exhibits the same issue under LLVM/Clang15

ld : error : undefined symbol: __start___modules [/root/runtime/src/coreclr/tools/aot/crossgen2/crossgen2.csproj]
##vso[task.logissue type=error;sourcepath=ld;linenumber=0;columnnumber=0;code=;](NETCORE_ENGINEERING_TELEMETRY=Build) undefined symbol: __start___modules
  >>> referenced by main.cpp:182 (/root/runtime/src/coreclr/nativeaot/Bootstrap/main.cpp:182)
  >>>               main.cpp.o:(main) in archive /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libbootstrapper.a
  >>> the encapsulation symbol needs to be retained under --gc-sections properly; consider -z nostart-stop-gc (see https://lld.llvm.org/ELF/start-stop-gc)
  
ld : error : undefined symbol: __stop___modules [/root/runtime/src/coreclr/tools/aot/crossgen2/crossgen2.csproj]
##vso[task.logissue type=error;sourcepath=ld;linenumber=0;columnnumber=0;code=;](NETCORE_ENGINEERING_TELEMETRY=Build) undefined symbol: __stop___modules
  >>> referenced by main.cpp:182 (/root/runtime/src/coreclr/nativeaot/Bootstrap/main.cpp:182)
  >>>               main.cpp.o:(main) in archive /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libbootstrapper.a
clang-15 : error : linker command failed with exit code 1 (use -v to see invocation) [/root/runtime/src/coreclr/tools/aot/crossgen2/crossgen2.csproj]
##vso[task.logissue type=error;sourcepath=clang-15;linenumber=0;columnnumber=0;code=;](NETCORE_ENGINEERING_TELEMETRY=Build) linker command failed with exit code 1 (use -v to see invocation)
/root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/build/Microsoft.NETCore.Native.targets(331,5): error MSB3073: The command ""/usr/local/bin/clang15" "/root/runtime/artifacts/obj/coreclr/crossgen2/x64/Release/native/crossgen2.o" -o "/root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/crossgen2/native/crossgen2" /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libbootstrapper.a /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libRuntime.ServerGC.a /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libstdc++compat.a /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libnumasupportdynamic.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Globalization.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.IO.Compression.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Net.Security.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread -ldl -lz -lrt -lm -pie -Wl,-z,relro -Wl,-z,now -L/usr/local/lib -lgssapi_krb5 -L/usr/local/lib -linotify -Wl,--discard-all -Wl,--gc-sections" exited with code 1. [/root/runtime/src/coreclr/tools/aot/crossgen2/crossgen2.csproj]
##vso[task.logissue type=error;sourcepath=/root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/build/Microsoft.NETCore.Native.targets;linenumber=331;columnnumber=5;code=MSB3073;](NETCORE_ENGINEERING_TELEMETRY=Build) The command ""/usr/local/bin/clang15" "/root/runtime/artifacts/obj/coreclr/crossgen2/x64/Release/native/crossgen2.o" -o "/root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/crossgen2/native/crossgen2" /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libbootstrapper.a /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libRuntime.ServerGC.a /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libstdc++compat.a /root/runtime/artifacts/bin/coreclr/freebsd.x64.Release/aotsdk/libnumasupportdynamic.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Globalization.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.IO.Compression.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Net.Security.Native.a /root/runtime/artifacts/bin/microsoft.netcore.app.runtime.freebsd-x64/Release/runtimes/freebsd-x64/native/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread -ldl -lz -lrt -lm -pie -Wl,-z,relro -Wl,-z,now -L/usr/local/lib -lgssapi_krb5 -L/usr/local/lib -linotify -Wl,--discard-all -Wl,--gc-sections" exited with code 1.

Would this fix only apply to ld.lld 13 or higher?

@am11
Copy link
Member

am11 commented Feb 2, 2023

We added UseLlvmLinker to remedy exactly this error on linux. -p:UseLlvmLinker=true on command-line or <UseLlvmLinker>true</UseLlvmLinker> in csrpoj.

@am11
Copy link
Member

am11 commented Feb 2, 2023

#80613 (comment)

@sec
Copy link
Contributor Author

sec commented Feb 2, 2023

We added UseLlvmLinker to remedy exactly this error on linux. -p:UseLlvmLinker=true on command-line or <UseLlvmLinker>true</UseLlvmLinker> in csrpoj.

Thanks - adding this seems to work fine with the build. does this PR makes sense to merge, as it's adding some RIDs for arm64 same way x64 was added then?

@am11
Copy link
Member

am11 commented Feb 2, 2023

@sec, I think it would be fine to change the defaults for FreeBSD with:

<UseLlvmLinker Condition="'$(UseLlvmLinker)' == '' and '$(TargetOS)' == 'freebsd'">true</UseLlvmLinker>

in Microsoft.NETCore.Native.Unix.targets top properties block. This way the user on FreeBSD will not need to set it (if someone is intentionally experimenting with gcc-toolchain on FreeBSD, they will still be able to do so with override properties: -p:UseLlvmLinker=false -p:CppCompilerAndLinker=gcc etc.).

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@jkotas
Copy link
Member

jkotas commented Feb 2, 2023

change the defaults for FreeBSD

I think it is a good idea. It can be done as a new PR.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 4, 2023
@sec sec deleted the freebsd.arm64.fix.nativeaot.build branch February 18, 2024 12:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants