Skip to content

run_python.sh: Add readlink to allow symlinks to compiler entry points to work correctly#27220

Open
kapouer wants to merge 1 commit into
emscripten-core:mainfrom
kapouer:patch-1
Open

run_python.sh: Add readlink to allow symlinks to compiler entry points to work correctly#27220
kapouer wants to merge 1 commit into
emscripten-core:mainfrom
kapouer:patch-1

Conversation

@kapouer

@kapouer kapouer commented Jun 30, 2026

Copy link
Copy Markdown

This allows symbol links to the the compiler to work. Without this change, if you have for example /usr/bin/emcc as a symlink for /usr/local/share/emscripten/emcc then it would not work.

Fixes: #27211

@sbc100

sbc100 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

I updated the PR description, please can you check that I got that it right?

@sbc100 sbc100 changed the title run_python.sh: readlink to global installs run_python.sh: Add readlink to allow symlinks to compiler entry points to work correctly Jun 30, 2026
@sbc100

sbc100 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

(also updated the title.. again, please check I'm correct)

@sbc100 sbc100 closed this Jun 30, 2026
@sbc100 sbc100 reopened this Jun 30, 2026
@sbc100

sbc100 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

It looks like there are a couple of valid failures on the arm64 macos bot:

/Users/distiller/emsdk/python/3.13.3_64bit/bin/python3: can't open file '/private/var/folders/vg/ldc8ffjj6ssdmh4txpd6tlf40000gn/T/emtest_4910fhtz/emscripten_test_other_v5ipcie4/.py': [Errno 2] No such file or directory
None
None
  test_toolchain_profiler (test_other.other.test_toolchain_profiler) ... FAIL (0.000s)
-- Looking for strtod - found

@sbc100

sbc100 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Ah, the problem is the -f flag is not support on macOS readlink.

According to Gemini:

If the goal is to allow $0 to be executed via a symlink (e.g., from /usr/local/bin/emprofile ), the standard POSIX / macOS-safe way
to resolve $0 without relying on readlink -f is:

# Fallback to $0 if readlink fails (i.e. when $0 is a regular file)
TARGET=$(readlink "$0" 2>/dev/null || echo "$0")
exec "$_EM_PY" -E "$(dirname "$TARGET")/tools/emprofile.py" "$@"

Comment thread tools/maint/run_python.sh
exit 1
fi

exec "$_EM_PY" -E "$0.py" "$@"

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.

You also need to update tools/maint/run_python_compiler.sh I think

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.

run_python, run_python_compiler could readlink -f

2 participants