Skip to content

Fix HTML5 lib LTO build with PTHREADS (#20275) #20858

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

Closed
wants to merge 1 commit into from

Conversation

ifiddynine
Copy link
Contributor

@ifiddynine ifiddynine commented Dec 6, 2023

This is workaround for a bug in wasm-ld.

We use WebGPU, pthread and PROXY_TO_PTHREAD and noticed a linker error in our release builds where we enable LTO:

wasm-ld: error: C:\Dev\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libhtml5.a(callback.o): attempt to add bitcode file after LTO (_emscripten_run_callback_on_thread)

Judging by other tickets this seems like the place to fix it, but let me know if that's wrong.

@sbc100
Copy link
Collaborator

sbc100 commented Dec 6, 2023

I think this shouldn't be need, but currently is due a bug in the linker.

Can you add a comment mentioning that this is workaround for what a bug in wasm-ld?

And perhaps add "Fixes #20275" to the PR description?

@ifiddynine ifiddynine changed the title Fix HTML5 lib LTO build with PTHREADS Fix HTML5 lib LTO build with PTHREADS (#20275) Jan 22, 2024
@ifiddynine
Copy link
Contributor Author

ifiddynine commented Jan 22, 2024

Totally forgot about this change, merged in latest + updated the title! Came across it again just now in 3.1.51

path='system/lib/html5',
filenames=['callback.c'])

return math_files + exit_files + other_files + iprintf_files + errno_files + html5_files
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC this move html5/callback.c from libhtml to libc.. or actually it seems maybe duplicates it in the two libraries?

@ifiddynine
Copy link
Contributor Author

Sorry for the delay, I revisited this just now - I believe this fix is the current correct way of doing it.

@@ -2038,7 +2038,7 @@ class libhtml5(Library):
cflags = ['-Oz', '-fno-inline-functions']
src_dir = 'system/lib/html5'
src_glob = '*.c'

force_object_files = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a comment here with a link LTO bug so we know to remove it when its no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would that be the same as the one below, or a new ticket?

Copy link
Collaborator

Choose a reason for hiding this comment

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

#20275 (can you also add it to the PR description)

@sbc100
Copy link
Collaborator

sbc100 commented Aug 19, 2024

This change should no longer be needed since llvm/llvm-project#101894 landed in llvm. Can you confirm this is no longer needed at your end?

@ifiddynine
Copy link
Contributor Author

Yup! I merged latest into our fork over the weekend but ran into other LTO issues - I'll get back to it soon and let you know. I think this fixed worked, but something else was acting up. Will let you know if it's our fault or not when I have time!

@sbc100
Copy link
Collaborator

sbc100 commented Sep 4, 2024

I think we can safely close this PR now

@sbc100 sbc100 closed this Sep 4, 2024
@ifiddynine ifiddynine deleted the patch-1 branch September 12, 2024 07:13
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