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

Failed to compile with multithreading with linker error #2255

Closed
mmatzev opened this issue Apr 12, 2020 · 8 comments
Closed

Failed to compile with multithreading with linker error #2255

mmatzev opened this issue Apr 12, 2020 · 8 comments
Labels
resolution: no fix needed Closed; no fix required (not a bug)

Comments

@mmatzev
Copy link

mmatzev commented Apr 12, 2020

I try to compile a design similar to the pulpissimo SoC from github.com/pulp-platform/pulpissimo. It works well with verilator as long as single-threading in selected.

If I add the option "--threads 4" I get the following error message:
/usr/bin/ld: _ZN9Verilated3t_sE: TLS reference in Vdimad01_digital_top__ALL.a(Vdimad01_digital_top__ALLcls.o) mismatches non-TLS definition in verilated.o section .bss
/usr/bin/ld: Vdimad01_digital_top__ALL.a: error adding symbols: bad value
collect2: error: ld returned 1 exit status

I used the Windows-Subsystem for Linux with the Debian distribution.

@mmatzev mmatzev added the new New issue not seen by maintainers label Apr 12, 2020
@wsnyder
Copy link
Member

wsnyder commented Apr 12, 2020

A google search of the error (minus verilator specifics) suggests:

" If you are compiling an application under Linux and get an error message like:
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in ...
The fix is quite simple: explicitly add #include <errno.h> to the offending file and then recompile.

So this would be to verilated.h. If this works please consider submitting a pull request to fix it.

If not, maybe there are other online suggestions.

@mmatzev
Copy link
Author

mmatzev commented Apr 12, 2020

I added the include in verilated.h as suggested and than the options "--threads" works.
But than the compile does not work any more without the option "--threads".
I tried also to place it in the "ifdef VL_THREADED" but it didn't help.

My change in my own repository:

Index: /home/vkr/ki_predict/iss_ki_predict/trunk/tools/wsl-debian/verilator/4.032/share/verilator/include/verilated.h
===================================================================
--- /home/vkr/ki_predict/iss_ki_predict/trunk/tools/wsl-debian/verilator/4.032/share/verilator/include/verilated.h     (revision 17)
+++ /home/vkr/ki_predict/iss_ki_predict/trunk/tools/wsl-debian/verilator/4.032/share/verilator/include/verilated.h     (working copy)
@@ -31,6 +31,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
+#include <errno.h>
 // <iostream> avoided to reduce compile time
 // <map> avoided and instead in verilated_heavy.h to reduce compile time
 // <string> avoided and instead in verilated_heavy.h to reduce compile time

@drichmond
Copy link

I also ran into this problem, but the solution above doesn't fix it

/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: _ZN9Verilated3t_sE: TLS reference in Vtop__ALL.a(Vtop__ALLcls.o) mismatches non-TLS definition in ../verilated.o section .bss

Still looking into other solutions

@drichmond
Copy link

Ignore my previous comment for now, not seeing it in some situations and I am seeing it in others. Will work to find out more.

@wsnyder wsnyder added status: asked reporter Bug is waiting for reporter to answer a question and removed new New issue not seen by maintainers labels Apr 19, 2020
@wsnyder
Copy link
Member

wsnyder commented May 27, 2020

Any feedback on if you got Verilator multithreading working? Would like to close this issue out. Thanks

@drichmond
Copy link

drichmond commented May 27, 2020 via email

@wsnyder wsnyder added resolution: no fix needed Closed; no fix required (not a bug) and removed status: asked reporter Bug is waiting for reporter to answer a question labels May 27, 2020
@wsnyder
Copy link
Member

wsnyder commented May 27, 2020

Great!

@wsnyder wsnyder closed this as completed May 27, 2020
@riteme
Copy link

riteme commented Feb 9, 2021

I ran into this problem when I tried to add either --threads 1 or --trace-threads 1 to Verilator.

I found that I just forgot to add -DVL_THREADED when compiling verilated.cpp into verilated.o by G++.

mortbopet added a commit to mortbopet/verilator that referenced this issue Jun 30, 2021
Related to the error of verilator#2255:
/usr/bin/ld: _ZN9Verilated3t_sE: TLS reference in ... mismatches non-TLS definition in verilated.o section .bss

Adding `#include <errno.h>` does not seem to provide a consistent fix - I think that the `#include <cerrno>` of verilated.cpp provides a conflicting definition of `errno` in some edge-cases. Adding the identical include in verilated.h (seems to) fix the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: no fix needed Closed; no fix required (not a bug)
Projects
None yet
Development

No branches or pull requests

4 participants