corert icon indicating copy to clipboard operation
corert copied to clipboard

Error building under macOS

Open theolivenbaum opened this issue 5 years ago • 6 comments
trafficstars

We're hitting this problem when trying to compile one of our projects under macOS, on an Azure devops VM:

ld: illegal text-relocation to '___ThreadStaticRegionEnd'

The same project builds fine on windows and linux.

The only solution I found online for this "illegal text-relocation" issue was to add -read_only_relocs suppress, but this is not anymore supported on macOS & x64.

There are two more warnings besides this error message:

/usr/bin/clang
Generating native code
ld : warning : -read_only_relocs cannot be used with x86_64 [/Users/runner/runners/2.165.2/work/1/s/Project.csproj]
ld : warning : could not create compact unwind for _System_Net_Security_System_Net_Security_TlsCipherSuiteData___cctor: stack subq instruction is too different from dwarf stack size [/Users/runner/runners/2.165.2/work/1/s/Project.csproj]
ld : warning : can't parse dwarf compilation unit info in obj/Debug/netcoreapp3.1/osx-x64/native/Project.o [/Users/runner/runners/2.165.2/work/1/s/Project.csproj]
ld: illegal text-relocation to '___ThreadStaticRegionEnd' in obj/Debug/netcoreapp3.1/osx-x64/native/Project.o from '___RMHSignature_MessagePack_Annotations_MessagePack_MessagePackFormatterAttribute__get_FormatterType' in obj/Debug/netcoreapp3.1/osx-x64/native/Project.o for architecture x86_64
clang : error : linker command failed with exit code 1 (use -v to see invocation) [/Users/runner/runners/2.165.2/work/1/s/Project.csproj]

Any ideas?

theolivenbaum avatar Mar 23 '20 16:03 theolivenbaum

Are you able to reproduce this even with a simple MessagePack program?

jkotas avatar Mar 23 '20 16:03 jkotas

Will try to create a small repro build for it. But it was hitting it from different methods - before was the same issue but with some method from the Microsoft.Extensions.DependencyInjection package

theolivenbaum avatar Mar 23 '20 18:03 theolivenbaum

Minimal project that fails on osx-x64, but works on win-x64.

corerttest.tar.gz

pfriesch avatar Mar 23 '20 19:03 pfriesch

Hmm, it looks very similar to https://github.com/dotnet/corert/issues/7265 that was supposed to be fixed by https://github.com/dotnet/corert/pull/7249 . I won't have access to a mac until things are back to normal - marking it as up-for-grabs if anybody is interested in looking into this.

jkotas avatar Mar 24 '20 03:03 jkotas

I try compile on Mac, but publishing was working

% clang --version
Apple clang version 11.0.3 (clang-1103.0.32.29)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Mac OS 10.15.3

kant2002 avatar Mar 27 '20 19:03 kant2002

I tried it again, but it does not compile to a binary. The same happens on the azure mac build environment.

Local build environment:

macOS: 10.15.4

% clang --version

Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
% dotnet publish /p:NativeLib=Shared -r osx-x64 -c Release

Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 82.36 ms for /Volumes/SD/projects2/CoreRTTest/Library.Python.csproj.
  Library.Python -> /Volumes/SD/projects2/CoreRTTest/bin/Release/netcoreapp3.1/osx-x64/Library.Python.dll
  /usr/bin/clang
  Generating native code
ld : warning : -read_only_relocs cannot be used with x86_64 [/Volumes/SD/projects2/CoreRTTest/Library.Python.csproj]
  ld: illegal text-relocation to '___ThreadStaticRegionEnd' in obj/Release/netcoreapp3.1/osx-x64/native/Library.Python.o from '___RMHSignature_System_Linq_System_Linq_Enumerable_Iterator_1<Int32>__Select<String>' in obj/Release/netcoreapp3.1/osx-x64/native/Library.Python.o for architecture x86_64
clang : error : linker command failed with exit code 1 (use -v to see invocation) [/Volumes/SD/projects2/CoreRTTest/Library.Python.csproj]
/Users/pfriesch/.nuget/packages/microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/build/Microsoft.NETCore.Native.targets(306,5): error MSB3073: The command "clang "obj/Release/netcoreapp3.1/osx-x64/native/Library.Python.o" -o "bin/Release/netcoreapp3.1/osx-x64/native/Library.Python.dylib" -exported_symbols_list "obj/Release/netcoreapp3.1/osx-x64/native/Library.Python.exports" -read_only_relocs suppress /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/sdk/libbootstrapperdll.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/sdk/libRuntime.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/sdk/libSystem.Private.CoreLib.Native.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/sdk/libSystem.Private.TypeLoader.Native.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/framework/System.Native.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/framework/System.Globalization.Native.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/framework/System.IO.Compression.Native.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/framework/System.Net.Security.Native.a /Users/pfriesch/.nuget/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-28830-01/framework/System.Security.Cryptography.Native.Apple.a -Wl,-rpath,'$ORIGIN' -lstdc++ -ldl -lm -lz -licucore -dynamiclib -framework CoreFoundation -framework Security -framework GSS" exited with code 1. [/Volumes/SD/projects2/CoreRTTest/Library.Python.csproj]

pfriesch avatar Apr 30 '20 09:04 pfriesch