-
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.
Nonstandard and as I mentioned above will break any projects which rightfully assume CMAKE_SYSROOT points to the actual 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.
Additionally, I'm pretty sure that the extra appended sysroot would be a no-op in most cases.
Even if so, I'd know that conforming to the expected set variables of CMake would be far more ideal than trying to use nonstandard.
For example I know a lot of projects who try to use assembly files because cmake's processor variable is set to the host instead of... well... something reasonable like "wasm64".
It's mostly due to the fact a lot of existing projects rightfully assume CMake provides accurate variables to the environment, what Emscripten is doing in this case is give a "half-answer" for most variables.
Of my particular note is CMAKE_SYSTEM_PROCESSOR (affects boost context, containers) and CMAKE_SYSROOT (shadPS4, openssl-cmakel) to metnion a few
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.