-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Use CMAKE_SYSROOT instead of EMSCRIPTEN_SYSROOT #27083
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
Open
xinitrcn1
wants to merge
1
commit into
emscripten-core:main
Choose a base branch
from
xinitrcn1:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason we don't do this is that
emccon it own already automatically includes the sysroot.i.e. you never need to do
emcc --sysroot=/path/to/emscripten/sysrootsinceemccalready knows exactly where its sysroot is. Its not something we expect user to pass.I think we don't really want
cmaketo inject and additional--sysrootsince it would be redundant.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we set the compiler to clang then it would make sense to pass things like
--sysrootand--target=wasm32-unknown-emscripten, but when we use the emcc wrapper around clang they are not needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware emcc itself uses --sysroot..
HOWEVER
many projects use ${CMAKE_SYSROOT} for other miscellany purpouses, most notably:
For example shadPS4 uses CMAKE_SYSROOT for checks and stuff, is it bad design? No! As per documentation CMAKE_SYSROOT MUST point to a valid sysroot, otherwise it's not a valid toolchain.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For find package we set
CMAKE_FIND_ROOT_PATH.For
pkg_configwe setPKG_CONFIG_LIBDIR.As I said, I'm to to keem on the idea of seeing
--sysroot=/path/to/default/sysrootadded to everyemcccommand line that cmake generates.@bradking, sorry to loop you in again here, but I'm not sure what the best approach is here. We do use a sysroot, but its location is already know the
emcc. I guess I'm looking for way to tell cmake about the sysroot without injecting superfluous/redundant compiler flags. Is that something is possible? Are we wrong to not setCMAKE_SYSROOT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like
DEFAULT_SYSROOTwhich would allow cmake to be aware or it without having to also inject--sysroot?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMAKE_SYSROOTis meant for passing--sysrootto the compiler, and is also used forfind_packageand such. If one only wants thefind_packagepart,CMAKE_FIND_ROOT_PATHshould be sufficient.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really?
I'm pretty sure by this point most projects [that worry about CMAKE_SYSROOT] have used it as an ad-hoc solution to get the sysroot they're living on (for whichever reason).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMake documentation for
CMAKE_SYSROOTstates:If projects are referencing
CMAKE_SYSROOTfor their own purposes, that's their own business, and they should be able to deal with it not being set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, Of which it says
I mean the docs of CMake w.r.t to CMAKE_SYSROOT mostly just imply that "it's a path", and yes, used for "find_*", but, if we were left to guess what the intention was, well, many people guessed that CMAKE_SYSROOT was a safe path to use to get the sysroot of the system when cross compiling. And now it's in various projects.
Was this correct to do? Eh... well that's how it's used nowadays (aside from the use outlined on CMake itself)
Here is varying examples of CMAKE_SYSROOT, all of them using it as ""intended"" https://man.freebsd.org/cgi/man.cgi?query=cmake-toolchains&sektion=7&manpath=FreeBSD+13.2-RELEASE+and+Ports
Except, annoyingly, " Cross Compiling using Clang" which doesn't. Allegedly because it assumes the toolchain itself already sets the sysroot by itself(?). But the whole document implies that a sysroot should be used.
Also wasi does it as well https://github.com/WebAssembly/wasi-sdk/blob/5faf80805397ae2a96ab224d1f103798af06dd92/cmake/wasi-sdk-sysroot.cmake#L67
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with wasi-sdk the
--sysrootargument is actually requires since the compiler it doesn't always know how to find it (unlike emcc).I do understand your frustration here though, and I agree that we should somehow weight the costs and benefits here of redundantly injecting
--sysroot.