Skip to content

Fix default setting of EXECUTABLE overriding the value set in phase_linker_setup() for autoconfiguring.#26822

Merged
juj merged 2 commits intoemscripten-core:mainfrom
juj:fix_autoconf_executable_override
Apr 30, 2026
Merged

Fix default setting of EXECUTABLE overriding the value set in phase_linker_setup() for autoconfiguring.#26822
juj merged 2 commits intoemscripten-core:mainfrom
juj:fix_autoconf_executable_override

Conversation

@juj
Copy link
Copy Markdown
Collaborator

@juj juj commented Apr 30, 2026

Fix default setting of EXECUTABLE overriding the value set in phase_linker_setup() for autoconfiguring.

This line has no effect:

emscripten/tools/link.py

Lines 829 to 830 in 2a8234f

# Add `#!` line to output JS and make it executable.
settings.EXECUTABLE = config.NODE_JS[0]

since it was being overridden by default_setting('EXECUTABLE', 1), which looks only in user_settings, and not if the setting has already been initialized.

The result is that all autoconfigures would get the default shebang

emscripten/tools/link.py

Lines 460 to 462 in 2a8234f

# By default, the resulting script will run under the version of node in the PATH.
if settings.EXECUTABLE == 1:
settings.EXECUTABLE = '/usr/bin/env node'

and attempt to run Node from PATH.

On my CI, I don't have a Node in PATH (exactly for the purposes of guarding against accidental 'wrong node' accesses like this). Fixes test_bullet_autoconf without Node in PATH: http://clbri.com:8010/api/v2/logs/406907/raw_inline

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Apr 30, 2026

So how does autoconf run the program if the resulting program has no #! line?

Comment thread tools/link.py
# linker setup phase may have initialized the EXECUTABLE setting already, so only init default here
# if not yet set.
if not settings.EXECUTABLE:
default_setting('EXECUTABLE', 1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should instead move the EMMAKEN_JUST_CONFIGURE block ~100 lines down so it comes after this?

If not maybe at least make this in to single if statement.

Comment thread tools/link.py Outdated
# making the resulting file exectuable.
if settings.ENVIRONMENT_MAY_BE_NODE and options.oformat == OFormat.JS and final_suffix in {'', '.out'}:
default_setting('EXECUTABLE', 1)
# linker setup phase may have initialized the EXECUTABLE setting already, so only init default here
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This code is still part of phase_linker_setup (i know, its huge).

How about autoconf handling above may have initialized the EXECUTABLE ..

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good.

@juj
Copy link
Copy Markdown
Collaborator Author

juj commented Apr 30, 2026

It is not a case of the resulting program not having a #! line, but it is a case of the program having a line #! /usr/bin/env node, which searches node from PATH, which is not found.

When autoconfiguring, the code did first force EXECUTABLE to an absolute path to node, but that logic gets overridden by the later default_setting('EXECUTABLE', 1), force-reverting the shebang away from #! /absolute/path/to/node to that #!/usr/bin/env node, failing the code.

@juj juj merged commit 5639320 into emscripten-core:main Apr 30, 2026
4 of 14 checks passed
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