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

Add better error message when mixing exceptions modes. NFC #23738

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

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Feb 24, 2025

Depends on llvm/llvm-project#128564 to allow wasm-ld to report the object file in question.

Fixes: #23732

Depends on llvm/llvm-project#128564 to allow
wasm-ld to report the object file in question.

Fixes: emscripten-core#23732
#if WASM_EXCEPTIONS
#if ASSERTIONS
// Try to give a more useful error message than simply `Undefined reference to `emscripten_longjmp`
emscripten_longjmp__deps: [() => error('undefined reference to `emscripten_longjmp`. One or more object files was not compiled with `-fwasm-exceptions`. Build with `-sASSERTIONS=0` to have wasm-ld report which one.')],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to confirm, -sASSERTIONS=0 is the default right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

-sASSERTIONS=1 is the default for -O0 but -sASSERTIONS=0 is the default of -O1 and above.

self.assertContained('error: undefined reference to `emscripten_longjmp`. One or more object files was not compiled with `-fwasm-exceptions`. Build with `-sASSERTIONS=0` to have wasm-ld report which one.', err)

err = self.expect_fail([EMCC, 'main.o', '-fwasm-exceptions', '-sASSERTIONS=0'])
self.assertContained('wasm-ld: error: main.o: undefined symbol: emscripten_longjmp', err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like a big improvement to me.

When Emscripten invokes wasm-ld it would be nice if it could detect this error and add the extra context about this since one doesn't see the instruction to pass -fwasm-exceptions as a cflag here. I assume we are already redirecting stderr when we invoke wasm-ld?

If it's too inconvenient this by itself is quite helpful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Emscripten doesn't currently capture and parse the output of wasm-ld. Its just fails if/when wasm-ld fails.

I'm not sure I want to go down the route of trying to get fancy with parsing the error output of wasm-ld. I decided that showing the more specific error when -O0 / -sASSERTIONS=1 are enabled was a good compromise.

@hoodmane
Copy link
Collaborator

What's the procedure for an emscripten change that requires an llvm change? You test emscripten locally against the llvm change and then wait for the llvm commit to land and then wait for the roller to ingest it and then rebase the emscripten pr?

@sbc100
Copy link
Collaborator Author

sbc100 commented Feb 25, 2025

What's the procedure for an emscripten change that requires an llvm change? You test emscripten locally against the llvm change and then wait for the llvm commit to land and then wait for the roller to ingest it and then rebase the emscripten pr?

Yes, exactly.

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.

Clearer linker error due to sjlj ABI mismatch?
3 participants