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

singlefilehost doesn't link to system libunwind #42661

Closed
omajid opened this issue Sep 24, 2020 · 6 comments · Fixed by #42689
Closed

singlefilehost doesn't link to system libunwind #42661

omajid opened this issue Sep 24, 2020 · 6 comments · Fixed by #42689

Comments

@omajid
Copy link
Member

omajid commented Sep 24, 2020

Trying to build runtime (commit 20710bb) with -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND is currently broken:

$ ./build.sh -cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE 
...
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `UnwindContextToWinContext(unw_cursor*, _CONTEXT*)':                                                      
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:176: undefined reference to `_ULx86_64_get_reg'                                                                                                          
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:177: undefined reference to `_ULx86_64_get_reg'                                                                                             
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:178: undefined reference to `_ULx86_64_get_reg'                                                                                             
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:179: undefined reference to `_ULx86_64_get_reg'                                                                                             
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:180: undefined reference to `_ULx86_64_get_reg'                                                                                             
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o):/home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:181: more undefined references to `_ULx86_64_get_reg' follow                                                                                                                                                                                                                      
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `GetContextPointer(unw_cursor*, ucontext_t*, int, unsigned long**)':                                      
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:227: undefined reference to `_ULx86_64_get_save_loc'                                                                                                     
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `PAL_VirtualUnwind':                                                                                      
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:340: undefined reference to `_ULx86_64_init_local'                                                                                                       
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:351: undefined reference to `_ULx86_64_step'                                                                                                
  /usr/bin/ld: /home/omajid/devel/dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:360: undefined reference to `_ULx86_64_is_signal_frame'                                                                                     
  clang-10: error: linker command failed with exit code 1 (use -v to see invocation)                                                                                                                                                          
  gmake[2]: *** [cli/apphost/static/CMakeFiles/singlefilehost.dir/build.make:282: cli/apphost/static/singlefilehost] Error 1                                                                                                                  
  gmake[1]: *** [CMakeFiles/Makefile2:510: cli/apphost/static/CMakeFiles/singlefilehost.dir/all] Error 2                                 

Configuration

  • Which version of .NET is the code running on?

dotnet/runtime commit 20710bbcae006e32f8a133c372c8d78722890982 as well as release/5.0-preview8 tag.

  • What OS and version, and what distro if applicable?

Fedora 32.

  • What is the architecture (x64, x86, ARM, ARM64)?

x64, but probably affects everything.

  • Do you know whether it is specific to that configuration?

Yes: building without -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND works

Regression?

Yes. This build configuration was supported in .NET Core 3.1 and we were using it in source-build to build on Fedora/RHEL. See dotnet/coreclr#17164 and dotnet/source-build#391

Other information

The fix is probably the along the lines of #42094: the singlefilehost needs to link to the system libunwind library.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Sep 24, 2020
@omajid omajid changed the title singlefilehost doesn't link to system libunwind correctly singlefilehost doesn't link to system libunwind Sep 24, 2020
@ghost
Copy link

ghost commented Sep 24, 2020

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@omajid
Copy link
Member Author

omajid commented Sep 24, 2020

I am working on a fix for this; will open a PR shortly

@ghost
Copy link

ghost commented Sep 24, 2020

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

@janvorli janvorli removed the untriaged New issue has not been triaged by the area owner label Sep 24, 2020
@janvorli janvorli added this to the 6.0.0 milestone Sep 24, 2020
@janvorli
Copy link
Member

@omajid I've set the milestone to 6.0, but now I feel we might need this for 5.0, am I right?

@omajid
Copy link
Member Author

omajid commented Sep 24, 2020

Ideally we would add it to 5.0 GA (or post GA if GA is absolutely frozen for now).

If this doesn't get added to 5.0, we still have some options: we can carry this as a patch in source-build or in our RPM packages. But that gets reviewed less thoroughly and becomes harder to maintain as runtime gets additional fixes.

I think we should decide to handle this issue consistently with #42094 and #42415: either all go to 5.0 or none of them go to 5.0.

@janvorli
Copy link
Member

There is still a window to get this in for 5.0 GA, let me update the milestone.

@janvorli janvorli modified the milestones: 6.0.0, 5.0.0 Sep 24, 2020
omajid added a commit to omajid/dotnet-runtime that referenced this issue Sep 25, 2020
We can now build runtime against the system libunwind using:

    ./build.sh -cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND

This allows Linux distributions that already ship a compatible version
of libunwind library to use that instead of carrying a duplicate in
.NET. This provides some benefits to them, including smaller build
sizes, slightly faster builds and fewer places to fix any
vulnerabilities

This functionality was already supported in .NET Core 3.1 and has
regressed since.

CoreCLR already handles `-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND`, so no
changes are needed there.

The libraries build doesn't care about this cmake varibale, but cmake
itself fails if the variable is not used:

    EXEC : CMake error : [runtime/src/libraries/Native/build-native.proj]
        Manually-specified variables were not used by the project:

          CLR_CMAKE_USE_SYSTEM_LIBUNWIND

So libraries just needs to check and ignore this variable.

The singlefilehost needs to link against libunwind too. Otherwise the
linker fails to resolve symbols, making the build fail:

    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `UnwindContextToWinContext(unw_cursor*, _CONTEXT*)':
      dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:176: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:177: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:178: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:179: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:180: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:181: more undefined references to `_ULx86_64_get_reg' follow
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `GetContextPointer(unw_cursor*, ucontext_t*, int, unsigned long**)':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:227: undefined reference to `_ULx86_64_get_save_loc'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `PAL_VirtualUnwind':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:340: undefined reference to `_ULx86_64_init_local'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:351: undefined reference to `_ULx86_64_step'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:360: undefined reference to `_ULx86_64_is_signal_frame'
    clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

Fixes: dotnet#42661
@ghost ghost closed this as completed in #42689 Sep 25, 2020
ghost pushed a commit that referenced this issue Sep 25, 2020
We can now build runtime against the system libunwind using:

    ./build.sh -cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND

This allows Linux distributions that already ship a compatible version
of libunwind library to use that instead of carrying a duplicate in
.NET. This provides some benefits to them, including smaller build
sizes, slightly faster builds and fewer places to fix any
vulnerabilities

This functionality was already supported in .NET Core 3.1 and has
regressed since.

CoreCLR already handles `-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND`, so no
changes are needed there.

The libraries build doesn't care about this cmake varibale, but cmake
itself fails if the variable is not used:

    EXEC : CMake error : [runtime/src/libraries/Native/build-native.proj]
        Manually-specified variables were not used by the project:

          CLR_CMAKE_USE_SYSTEM_LIBUNWIND

So libraries just needs to check and ignore this variable.

The singlefilehost needs to link against libunwind too. Otherwise the
linker fails to resolve symbols, making the build fail:

    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `UnwindContextToWinContext(unw_cursor*, _CONTEXT*)':
      dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:176: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:177: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:178: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:179: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:180: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:181: more undefined references to `_ULx86_64_get_reg' follow
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `GetContextPointer(unw_cursor*, ucontext_t*, int, unsigned long**)':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:227: undefined reference to `_ULx86_64_get_save_loc'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `PAL_VirtualUnwind':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:340: undefined reference to `_ULx86_64_init_local'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:351: undefined reference to `_ULx86_64_step'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:360: undefined reference to `_ULx86_64_is_signal_frame'
    clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

Fixes: #42661
github-actions bot pushed a commit that referenced this issue Sep 29, 2020
We can now build runtime against the system libunwind using:

    ./build.sh -cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND

This allows Linux distributions that already ship a compatible version
of libunwind library to use that instead of carrying a duplicate in
.NET. This provides some benefits to them, including smaller build
sizes, slightly faster builds and fewer places to fix any
vulnerabilities

This functionality was already supported in .NET Core 3.1 and has
regressed since.

CoreCLR already handles `-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND`, so no
changes are needed there.

The libraries build doesn't care about this cmake varibale, but cmake
itself fails if the variable is not used:

    EXEC : CMake error : [runtime/src/libraries/Native/build-native.proj]
        Manually-specified variables were not used by the project:

          CLR_CMAKE_USE_SYSTEM_LIBUNWIND

So libraries just needs to check and ignore this variable.

The singlefilehost needs to link against libunwind too. Otherwise the
linker fails to resolve symbols, making the build fail:

    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `UnwindContextToWinContext(unw_cursor*, _CONTEXT*)':
      dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:176: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:177: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:178: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:179: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:180: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:181: more undefined references to `_ULx86_64_get_reg' follow
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `GetContextPointer(unw_cursor*, ucontext_t*, int, unsigned long**)':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:227: undefined reference to `_ULx86_64_get_save_loc'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `PAL_VirtualUnwind':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:340: undefined reference to `_ULx86_64_init_local'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:351: undefined reference to `_ULx86_64_step'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:360: undefined reference to `_ULx86_64_is_signal_frame'
    clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

Fixes: #42661
agocke pushed a commit that referenced this issue Oct 2, 2020
We can now build runtime against the system libunwind using:

    ./build.sh -cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND

This allows Linux distributions that already ship a compatible version
of libunwind library to use that instead of carrying a duplicate in
.NET. This provides some benefits to them, including smaller build
sizes, slightly faster builds and fewer places to fix any
vulnerabilities

This functionality was already supported in .NET Core 3.1 and has
regressed since.

CoreCLR already handles `-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND`, so no
changes are needed there.

The libraries build doesn't care about this cmake varibale, but cmake
itself fails if the variable is not used:

    EXEC : CMake error : [runtime/src/libraries/Native/build-native.proj]
        Manually-specified variables were not used by the project:

          CLR_CMAKE_USE_SYSTEM_LIBUNWIND

So libraries just needs to check and ignore this variable.

The singlefilehost needs to link against libunwind too. Otherwise the
linker fails to resolve symbols, making the build fail:

    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `UnwindContextToWinContext(unw_cursor*, _CONTEXT*)':
      dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:176: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:177: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:178: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:179: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:180: undefined reference to `_ULx86_64_get_reg'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:181: more undefined references to `_ULx86_64_get_reg' follow
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `GetContextPointer(unw_cursor*, ucontext_t*, int, unsigned long**)':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:227: undefined reference to `_ULx86_64_get_save_loc'
    /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `PAL_VirtualUnwind':
      runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:340: undefined reference to `_ULx86_64_init_local'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:351: undefined reference to `_ULx86_64_step'
    /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:360: undefined reference to `_ULx86_64_is_signal_frame'
    clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

Fixes: #42661

Co-authored-by: Omair Majid <[email protected]>
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants