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

Build error on RISC-V 64bits system #222

Closed
OctopusET opened this issue Jan 1, 2022 · 12 comments · Fixed by #232
Closed

Build error on RISC-V 64bits system #222

OctopusET opened this issue Jan 1, 2022 · 12 comments · Fixed by #232

Comments

@OctopusET
Copy link
Contributor

OctopusET commented Jan 1, 2022

Error

When I was trying to build with make -j$(nproc) on riscv64(QEMU) Debian unstable, I get this error.

error: '__TBB_machine_fetchadd4' was not declared in this scope
348 | return __TBB_machine_fetchadd4(ptr, 1) + 1L;

I found similar error https://bugs.funtoo.org/browse/FL-8615?attachmentSortBy=fileName

Fix

  • And I fixed with this patch

  • Or using this patch would work too.

-    return __TBB_machine_fetchadd4(ptr, 1) + 1L;
+    return __atomic_fetch_add(ptr, 1L, __ATOMIC_SEQ_CST) + 1L;

And I got another error after patch.

undefined reference to `__atomic_exchange_1'

I fixed it with this.

-LIBS = -pthread -lz -ldl -lm
+LIBS = -pthread -lz -ldl -lm -latomic



Although those patches fix build error, but upstream onetbb does not require any patch when I was building on same system, it seems like they removed Arch specific code. I think updating onetbb to upstream will be better option.

References:

@OctopusET
Copy link
Contributor Author

Please let me know what would you think the best solution, I can make PR. Thanks

@rui314
Copy link
Owner

rui314 commented Jan 1, 2022

Thank you for testing this on RISC-V!

It looks like upgrading onetbb is the best option if it solves the problem for you and doesn't have any regression. Let me take a look.

@OctopusET
Copy link
Contributor Author

Thank you for response!

Please let me know if there is anything I can do.

@rui314
Copy link
Owner

rui314 commented Jan 2, 2022

I updated our oneTBB subtree to v2021.5.0, the latest stable version of the library. Can you try again to see if it builds on RISC-V?

@OctopusET
Copy link
Contributor Author

OctopusET commented Jan 2, 2022

@rui314 Thank you for work.

Seems like v2021.5.0 does not including commit (uxlfoundation/oneTBB@6fad698), PR (uxlfoundation/oneTBB#550)

So it's not able to build. And adding -latomic on Makefile still needed.
But just patching above commit fixes build problem.

What about patching that commit until new stable version came out?

ps:
What about using submodule for handling third-party project? (like onetbb) I think it would be easier to maintain and update them.

@rui314
Copy link
Owner

rui314 commented Jan 2, 2022

Do you mind if I ask you to create a patch and send me a pull request? I can make a change for you, but I cannot verify that myself, so it is probably faster for you to fix it on your side and let me just merge your change.

As to subtree/submodule, I used to be managing third-party libraries as submodule, but subtree was easier for me to manage them. At least it is simpler than submodule.

@OctopusET
Copy link
Contributor Author

@rui314 Sure, I will send PR soon, but I'd like to test mold on RISC-V. Will make test just work for basic test?

@rui314
Copy link
Owner

rui314 commented Jan 2, 2022

@OctopusET make test will run all tests. If you want to run only a few basic tests, please directly run test scripts in test/elf such as test/elf/hello-dynamic.sh.

@OctopusET
Copy link
Contributor Author

@rui314 I've should test before, seems like mold does not support RISC-V elf.
Anyway build is now okay, so I will send PR soon.

@rui314
Copy link
Owner

rui314 commented Jan 3, 2022

I'd like to port mold to RV64 which shouldn't be too hard. Your patch is I think a first step towards that.

@aaronfranke
Copy link

Hi, which version of Mold added support for RISC-V? I want to be able to document the minimum required version.

@rui314
Copy link
Owner

rui314 commented Sep 5, 2024

mold got RISC-V support back in 2022. So all versions since the license was changed to MIT should support RISC-V. That being said, we've been fixing several issues since then, so I'm not sure if older versions would work fine in the modern environment. mold is still a relatively young project. I'd pick a fairly recent version (e.g. within one year) and recommend it as a minimum required version. Note that we do not support older versions other than the latest one and will not fix bugs for those versions.

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 a pull request may close this issue.

3 participants