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

Fixes to libretro makefile for emscripten builds #878

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JoeOsborn
Copy link

Now that we can support threads in emscripten, this Makefile should be modified.

I ran into duplicate symbol problems when compiling PCSX's thread support, so I had to disable threads within the emulator to avoid duplicates of rthread.o. I'd appreciate advice in general on working with cores that could have threading support and including libretro-common under static linking scenarios (since retroarch also includes libretro-common).

@notaz
Copy link
Collaborator

notaz commented Feb 12, 2025

"pthread ?= 0" at the top misleadingly suggests it applies to many things when it's really emscripten specific. And there are plenty of confusing variables already...

Also no need for NDRC_THREAD as it only effects dynamic recompiler, which is naturally off for emscripten.

For clashing objects I've started using partial linking, see PARTIAL_LINKING in the main Makefile. No idea if something like that exists for emscripten.

@JoeOsborn
Copy link
Author

I agree re: pthread ?= 0, would you prefer that happen in the existing if platform check or in a new if platform check at the top? Putting defaults at the top has some benefits but I can also see an argument for just dropping that into the emscripten block.

For NDRC_THREAD, I actually found that emu_if.c was compiling in some thread stuff even under emscripten if pthread was turned on. So maybe there’s a bug in the preprocessor statements there?

As for partial linking I’m actually not sure what emscripten will do. I’ll give it a try tomorrow.

@JoeOsborn
Copy link
Author

I had a chance to look at partial linking after all. I think it could work but the issue isn’t the libretro api, it’s the libretro-common stuff like rthread.o (and I think wasmld doesn’t use linker scripts: emscripten-core/emscripten#23637 (comment) ).

I suspect an additional branch in the makefile (partial linking and emscripten) would call wasm-ld with default hidden visibility, and only make visible the libretro api symbols? Or, some LDFLAGS could be used to do that on emscripten in all emscripten builds.

@notaz
Copy link
Collaborator

notaz commented Feb 13, 2025

Unless it affects anything else, please keep it in the emscripten block.

Seems like emu_if.c was just including some unnecessary headers, I've updated it now.

For the threading stuff I'd suggest hacking something up locally and testing it to see if there's any real benefit first (if any of it works at all). All those complications might be just not worth the effort.

@JoeOsborn
Copy link
Author

Yeah, I'm working on pthread-enabling all of retroarch on emscripten, so if cores can compile with threads I figured I may as well compile them with threads assuming there's a reason they use threads on native in the first place. I'll do some more investigation.

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