Skip to content

Avoid changing working directory EMCC_BATCH_BUILD is unset. NFC#26812

Merged
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:build_cwd
Apr 29, 2026
Merged

Avoid changing working directory EMCC_BATCH_BUILD is unset. NFC#26812
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:build_cwd

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented Apr 28, 2026

When not using EMCC_BATCH_BUILD the working directory does not matter.

@kripken
Copy link
Copy Markdown
Member

kripken commented Apr 29, 2026

When not using EMCC_BATCH_BUILD the working directory does not matter.

This is a large file and after skimming relevant parts I'm not sure how to convince myself that is the case?

@sbc100
Copy link
Copy Markdown
Collaborator Author

sbc100 commented Apr 29, 2026

When not using EMCC_BATCH_BUILD the working directory does not matter.

This is a large file and after skimming relevant parts I'm not sure how to convince myself that is the case?

Firstly, this change only effects users who do EMCC_BATCH_BUILD=0.. which is just me occasionally i think.

The default use case EMCC_BATCH_BUILD=1 is unchanged.

The reason EMCC_BATCH_BUILD=1 needs to control the CWD is that it uses relative paths to refer to the source files:

See:

# Use relative paths to reduce the length of the command line.                               
# This allows to avoid switching to a response file as often.                                
src = os.path.relpath(src, build_dir)

This only happens for the batch builder, and its one of the reasons I don't like the batch builder: Because all the errors like ../../../system/libc/myfile.c. This means that filenames in the error message are less useful. With the non-batch builder all the filenames are absolute.

When not using `EMCC_BATCH_BUILD` the working directory does not
matter.
Copy link
Copy Markdown
Collaborator Author

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

I refactored and added some comments.

@sbc100 sbc100 merged commit 70de2ad into emscripten-core:main Apr 29, 2026
30 checks passed
@sbc100 sbc100 deleted the build_cwd branch April 29, 2026 20:18
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.

2 participants