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

Allow passing RTLIB=compiler-rt to avoid linking in libatomic even on Linux #3597

Closed

Conversation

justinkb
Copy link
Contributor

Not all linux users will have libatomic installed. When using clang as the system compiler with compiler-rt as the default runtime library instead of libgcc, atomic builtins may be provided by compiler-rt.

This change allows such users to pass RTLIB=compiler-rt to make sure the build doesn't error out on the missing (unnecessary) libatomic. Needless to say, this commit doesn't change anything if said flag isn't passed

@vondele
Copy link
Member

vondele commented Jul 3, 2021

IIUC this adds an additional flag that the user has to specify. Is there an easy way this could be found automatically? It might not be possible, in which case this seems a reasonable way.

@justinkb
Copy link
Contributor Author

justinkb commented Jul 3, 2021 via email

@vondele
Copy link
Member

vondele commented Jul 3, 2021

right, but I mean, is there a way so that the user doesn't need to specify the flag, and we just do the right thing.

@justinkb
Copy link
Contributor Author

justinkb commented Jul 3, 2021 via email

@vondele
Copy link
Member

vondele commented Jul 3, 2021

OK, looks good. Always nice to see SF be part of a distro.

@vondele
Copy link
Member

vondele commented Jul 3, 2021

btw, I had this question actually yesterday, what's the distro that doesn't have libstdc++ ?

@vondele vondele added the to be merged Will be merged shortly label Jul 3, 2021
@vondele vondele closed this in 516ad1c Jul 3, 2021
@justinkb
Copy link
Contributor Author

justinkb commented Jul 3, 2021

On Exherbo Linux (source based distribution), we have libstdc++ (and most exherbo dev/users do have it installed) 'packaged', but we have an alternatives system where you can switch your system compiler toolchain (amongst other things). LLVM's clang is the alternative, and it can be built in such a way to be self-hosting and built against LLVM's libc++ instead of libstdc++. Furthermore, it can be built so it uses the compiler-rt runtime over libgcc, so it doesn't rely on any part of gcc. (A fully libstdc++less system is still experimental by the way, my changes to the gcc toolchain haven't been merged yet, gcc currently has a post-dependency for libstdc++ for convenience). (And libatomic is a dependency of libstdc++, and if you don't have that installed, there's no need to have libatomic either). Hope that clears things up :)

@ppigazzini
Copy link
Contributor

msys2 provides different clang packages:

  • under mingw and ucrt environments: use libstdc++
  • under clang environment: use libc++ (and -latomic must be dropped). This is used also to build for Windows-ARM (seriously, not joking)

MichaelB7 pushed a commit to MichaelB7/Stockfish that referenced this pull request Jul 6, 2021
Not all linux users will have libatomic installed.
When using clang as the system compiler with compiler-rt as the default
runtime library instead of libgcc, atomic builtins may be provided by compiler-rt.
This change allows such users to pass RTLIB=compiler-rt to make sure
the build doesn't error out on the missing (unnecessary) libatomic.

closes official-stockfish#3597

No functional change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to be merged Will be merged shortly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants