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

Remove unused freebsd elf32/elf64 header references #107657

Merged

Conversation

omajid
Copy link
Member

@omajid omajid commented Sep 10, 2024

It doesn't make sense to require the freebsd-specific headers on non-FreeBSD platforms. In fact, on my testing, the headers aren't even used. And just break or do the wrong things when system libunwind is used.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Sep 10, 2024
It doesn't make sense to require the freebsd-specific headers on
non-FreeBSD platforms. In fact, on my testing, the headers aren't even
used. And just break or do the wrong things when system libunwind is
used.
@omajid
Copy link
Member Author

omajid commented Sep 11, 2024

cc @sec @Thefrank @joperator

@omajid omajid marked this pull request as ready for review September 11, 2024 11:21
@omajid
Copy link
Member Author

omajid commented Sep 11, 2024

cc @am11

@lambdageek
Copy link
Member

It's not really a freebsd specific header - it's just the ELF spec.

But that said it doesn't seem like any of the ELF stuff is used by the dwarf writer. So it's ok to remove

@Thefrank
Copy link
Contributor

It should be safe to remove.

FreeBSD builds currently use their own libunwind copy and I don't see anywhere else those ELF spec files would be used for FreeBSD.

@am11
Copy link
Member

am11 commented Sep 11, 2024

Yup, it's not related to freebsd, it was done as part of the consolidation work omajid@d2264b2, since HP libunwind has ditto headers under freebsd directory.

But that said it doesn't seem like any of the ELF stuff is used by the dwarf writer. So it's ok to remove.

Just make sure it's not breaking windows builds, since it's under HOST_WIN32.

@lambdageek lambdageek merged commit 171f1a7 into dotnet:main Sep 11, 2024
79 of 81 checks passed
@omajid
Copy link
Member Author

omajid commented Sep 16, 2024

Does this meet the bar for backporting to 9.0?

Without this change, .NET incorrectly uses the bundled libunwind (or fails to build if the bundled libunwind sources have been deleted as a preventive measure) even on x64 with a command like this:

./build.sh /p:NoPgoOptimize=true --portablebuild false /p:DotNetBuildFromSource=true /p:DotNetBuildSourceOnly=true /p:DotNetBuildTests=true --cmakeargs -DCLR_CMAKE_USE_SYSTEM_BROTLI=true --cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=true --cmakeargs -DCLR_CMAKE_USE_SYSTEM_RAPIDJSON=true --cmakeargs -DCLR_CMAKE_USE_SYSTEM_ZLIB=true --runtimeconfiguration Release --librariesConfiguration Debug /p:PrimaryRuntimeFlavor=Mono --warnAsError false --subset clr+mono+libs+host+packs+libs.tests

@am11
Copy link
Member

am11 commented Sep 16, 2024

Without this change, .NET incorrectly uses the bundled libunwind

What is the error message and on which platform? This is used by mono-windows as a header only include. It doesn't compile the libunwind.

@omajid
Copy link
Member Author

omajid commented Sep 16, 2024

What is the error message and on which platform?

In our CI setup, when using system libraries, we rm the bundled libunwind implementation. The leg that builds on x64 with mono fails with:

  -- Configuring done (29.3s)
  CMake Error at mono/utils/CMakeLists.txt:257 (add_library):
    Cannot find source file:
  
      /home/tester/runtime/src/native/external/libunwind/include/remote/freebsd-elf_common.h
  
  
  -- Generating done (0.1s)
  CMake Warning:
    Manually-specified variables were not used by the project:
  
      CLR_CMAKE_USE_SYSTEM_LIBUNWIND
      CLR_CMAKE_USE_SYSTEM_RAPIDJSON
  

@am11
Copy link
Member

am11 commented Sep 16, 2024

we rm the bundled libunwind implementation.

To avoid accidental building? I see this rationale, but isn't it a bit too eager; considering llvm-libunwind in the same src/native/external directory is kept (because we can't use the stock version of that lib as no one has upstreamed the patches); why this treatment is exclusive for HP libunwind? 😅

You could keep the remote directory and delete the rest:

- rm src/native/external/libunwind
+ find src/native/external/libunwind -mindepth 1 ! -regex '^src/native/external/libunwind/include/remote\(/.*\)?' -delete

@omajid
Copy link
Member Author

omajid commented Sep 17, 2024

Okay, that's fair. Thanks!

jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 17, 2024
These headers define the ELF structures, but the mono DWARF writer doesn't actually use them for anything.  The headers may conflict when system libunwind is used.
sirntar pushed a commit to sirntar/runtime that referenced this pull request Sep 30, 2024
These headers define the ELF structures, but the mono DWARF writer doesn't actually use them for anything.  The headers may conflict when system libunwind is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Build-mono 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.

5 participants