Skip to content

Build a complete sysroot in the cache directory #13090

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

Merged
merged 1 commit into from
Jan 10, 2021
Merged

Build a complete sysroot in the cache directory #13090

merged 1 commit into from
Jan 10, 2021

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Dec 22, 2020

Rather than adding various include paths, copy any needed headers into
the sysroot along with any libraries.

This means that emscripten can work a lot more like the
traditional cross compiler (e.g. clang -target=xxx --sysroot=yyy),
and we can start to think of the emscripten driver as a seperate
thing to the sysroot.

Fixes: #9353

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the overall change is to the cache? I see reconfiguring is not needed, but I'm not sure why. In other words, what does the cache look like after this change?

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 6, 2021

The reason reconfiguring if the cache is no longer necessary is that we no longer user separate cache directories for different configurations. Instead the cache directory is fixed and never changes, but the libraries being uses live in different sub-directories of the cache.

Old layout:

cache/wasm/libc.a
cache/wasm/cache.lock
cache/wasm-lto/libc.a,
cache/wasm-lto/cache.lock

New layout:

cache/cache.lock
cache/sysroot/include  (shared include dir)
cache/sysroot/lib/wasm32-emscripten/libc.a
cache/sysroot/lib/wasm32-emscripten/lto/libc.a

(not only one cache.lock exists because there is only ever one cache directory).

If you like I can take the changes relating to removing reconfigurability and separate them out and land them first? Then we could have the same layout as today but all within a single structured cache directory. Would that make it easier to review and safer to land?

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. Approach sgtm. The only possible downside is that before with separate cache dirs we could clear just one at a time, but I don't think we actually did that - we cleared it all. So I think this has no downsides, and only upsides.

If you like I can take the changes relating to removing reconfigurability and separate them out and land them first?

From a review point of view I'm fine either way. But that might make it safer to land, so it might be worth it.

One specific thing I worry about is our precompiled libraries support in the emsdk, which needs to be copied to the right place - I assume we'll need emsdk changes for this too?

sbc100 added a commit that referenced this pull request Jan 8, 2021
This was split out from the change to use a single sysroot (#13090).  I
think it cleaner this way: There is single cache, with single lock file
and the root doesn't change, but the libraries live in sub-directories
within the cache.
sbc100 added a commit that referenced this pull request Jan 8, 2021
This was split out from the change to use a single sysroot (#13090).  I
think it cleaner this way: There is single cache, with single lock file
and the root doesn't change, but the libraries live in sub-directories
within the cache.
sbc100 added a commit that referenced this pull request Jan 8, 2021
This was split out from the change to use a single sysroot (#13090).  I
think it cleaner this way: There is single cache, with single lock file
and the root doesn't change, but the libraries live in sub-directories
within the cache.
sbc100 added a commit that referenced this pull request Jan 8, 2021
This was split out from the change to use a single sysroot (#13090).  I
think it cleaner this way: There is single cache, with single lock file
and the root doesn't change, but the libraries live in sub-directories
within the cache.
sbc100 added a commit that referenced this pull request Jan 8, 2021
This was split out from the change to use a single sysroot (#13090).  I
think it cleaner this way: There is single cache, with single lock file
and the root doesn't change, but the libraries live in sub-directories
within the cache.
sbc100 added a commit that referenced this pull request Jan 8, 2021
This was split out from the change to use a single sysroot (#13090).  I
think it cleaner this way: There is single cache, with single lock file
and the root doesn't change, but the libraries live in sub-directories
within the cache.
@sbc100 sbc100 force-pushed the use_sysroot branch 4 times, most recently from 0065f6a to 356b56d Compare January 9, 2021 16:41
Rather than adding various include paths, copy any needed headers into
the sysroot along with any libraries.

This means that emscripten can work a lot more like the
traditional cross compiler (e.g. clang -target=xxx --sysroot=yyy),
and we can start to think of the emscripten driver as a seperate
thing to the sysroot.

Fixes: #9353
@sbc100 sbc100 merged commit 298b2af into master Jan 10, 2021
@sbc100 sbc100 deleted the use_sysroot branch January 10, 2021 12:09
@juj
Copy link
Collaborator

juj commented Jan 22, 2021

I believe after this change iterating work on system headers has become astronomically slower, as one needs to do emcc --clear-cache always after editing a header file, which triggers all the system libs to build.

Is there a way to get the old behavior back, or have a mode where one has fast access to iterating on system headers, which does not need either manual deployment of headers after each edit, or the process is somehow automated e.g. by checking timestamps on the source files?

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 22, 2021

Yes I agree we could make it a little smoother.

I've also forgotten to run ./embuilder build sysroot --force when working on system headers. I think maybe some kind of timestamp checker that is only enabled for git developers might work.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 22, 2021

By the way, this was already true when editing source files in the system directory. The developer has to know to run ./embuilder --force <library_name> or ./emcc --clear-cache.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 22, 2021

Is knowing about ./embuilder build sysroot --force enough to make you workflow fast again for the time being?

@juj
Copy link
Collaborator

juj commented Jan 22, 2021

By the way, this was already true when editing source files in the system directory. The developer has to know to run ./embuilder --force <library_name> or ./emcc --clear-cache.

That is true. In this case I am working on WebGPU header and JS library files, where the .h files now need a embuilder build step, but looks like JS library files at least do not.

Is knowing about ./embuilder build sysroot --force enough to make you workflow fast again for the time being?

Yes, thanks, I can patch that in to my build cmdline for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moving towards a more traditional sysroot from emcc
3 participants