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

Only allow absolute paths for EM_CONFIG/EM_CACHE, etc. #23402

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 14, 2025

Allowing relative paths here breaks when emcc is run as a subprocess in a different directory. This happens in when building system libraries in batch build mode.

One alternative to doing this would be convert all these paths to absolute paths when we read them and then re-export them with those different values for our sub-processes, but that seems more complex and error prone than just requiring them to be absolute in the first place.

I'm also not sure it makes much sense to use relative paths here since if the environment contains a relative path then the compiler cannot be used from different directories. e.g.

$ export EM_CACHE=foo
$ emcc hello.c
$ cd foo && emcc foo.c  # confusingly would use a different cache

Fixes: #23374

Allowing relative paths here breaks when emcc is run as a subprocess
in a different directory.  This happens in when building system
libraries in batch build mode.

One alternative to doing this would be convert all these paths to
absolute paths when we read them and then re-export them with those
different values for our sub-processes, but that seems more complex and
error prone than just requiring them to be absolute in the first place.

I'm also not sure it makes much sense to use relative paths here since
if the environment contains a relative path then the compiler cannot be
used from different directories.  e.g.

```
$ export EM_CACHE=foo
$ emcc hello.c
$ cd foo && emcc foo.c  # confusingly would use a different cache
```

Fixes: emscripten-core#23374
@dschuff
Copy link
Member

dschuff commented Jan 14, 2025

I think this is a good idea. Unlike, say, a config file, an environment variable is going to be specific to a particular installation or environment and won't move between systems.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 14, 2025

You also don't want the environment variable to effectively move ever time you do cd, right?

@dschuff
Copy link
Member

dschuff commented Jan 14, 2025

You also don't want the environment variable to effectively move ever time you do cd, right?

Right, I would expect the cache location not to be relative to the working directory. If it's relative to anything, it seems like it should be the emscripten root. Even if for some reason you do want a separate cache for, say, every build project, you can still accomplish that with the build system.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 15, 2025

OK to land this?

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.

Embuilder cannot handle relative paths for cache
2 participants