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

Issue Linking on Mac OS #1486

Closed
veripoolbot opened this issue Aug 1, 2019 · 12 comments
Closed

Issue Linking on Mac OS #1486

veripoolbot opened this issue Aug 1, 2019 · 12 comments
Labels
resolution: no fix needed Closed; no fix required (not a bug)

Comments

@veripoolbot
Copy link
Contributor


Author Name: Joseph Shaker
Original Redmine Issue: 1486 from https://www.veripool.org


Hi all, I;ve used verilator for a while on Linux and have had no problems, however I wanted to start running it on my mac and have been struggling.
I am currently trying to compile and test a module I've written. Verilator compiles to C++ fine, then when I run make -f Vaudio_test.mk, and then make all, g++ complains

Please find attached the Makefile I generated, the ones that verilator generated, and the archive file generated

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-08-01T16:56:17Z


Looks like you used a GCC or set of GCC -march flags to make the .a (this might have come vis the GCC you used to configure verilator), and a different set of flags for your larger program.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-08-01T17:02:41Z


BTW it might help to rely on Verilator to do it all....

  verilator {all-flags-used-previously} --exe audio_test.cpp

then make will also build and link your CPP file.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Joseph Shaker
Original Date: 2019-08-01T17:04:32Z


Wilson Snyder wrote:

Looks like you used a GCC or set of GCC -march flags to make the .a (this might have come vis the GCC you used to configure verilator), and a different set of flags for your larger program.

I installed verilator using "brew" which is a macos package manager. Do you think that compiling verilator from scratch oon my machine would help keep the configurations consistent?

Verilator made the .mk file that made the .a file so I am not exactly sure how verilator picks the archetecture to build for. There were a few flags in the man page that were highlighted as deprecated, such as "VM_SC_TARGET_ARCH". When I generated the .mk file it originally was said to "linux", and I manually changed it to darwin but that did not help

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-08-01T17:16:45Z


You're not using SystemC so VM_SC_* won't matter.

Look at what commands make prints when you build the archive then your application. See if the path to GCC is the same and the compiler flags are the same, if not try running the commands yourself using the same gcc/flags.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Joseph Shaker
Original Date: 2019-08-01T23:48:57Z


Wilson Snyder wrote:

You're not using SystemC so VM_SC_* won't matter.

Look at what commands make prints when you build the archive then your application. See if the path to GCC is the same and the compiler flags are the same, if not try running the commands yourself using the same gcc/flags.

I noticed that my makefile is by default using clang++.
I reran the commands that script was running manually using g++, and then tried linking and still had problems.
I also tried building the default way and then compiling my final program with clang++
All gave the same final error

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Joseph Shaker
Original Date: 2019-08-01T23:50:42Z


Joseph Shaker wrote:

Wilson Snyder wrote:

You're not using SystemC so VM_SC_* won't matter.

Look at what commands make prints when you build the archive then your application. See if the path to GCC is the same and the compiler flags are the same, if not try running the commands yourself using the same gcc/flags.

I noticed that my makefile is by default using clang++.
I reran the commands that script was running manually using g++, and then tried linking and still had problems.
I also tried building the default way and then compiling my final program with clang++
All gave the same final error

Using the verilator command with --exe in the end and then invoking the auto generated makefile led to the same errors

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Joseph Shaker
Original Date: 2019-08-01T23:52:05Z


Here are the files in my directory. All the intermediate object files seem to be built for the correct archetecture ...

https://pastebin.com/95ufpM15

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-08-03T12:22:02Z


Maybe your "ar" is broken somehow? Try making a single "g++" command, where the file you specify has an #include of every .cpp file that needs to be compiled.

Verilator has a tool to help

verilator_includer  audio_test.cpp Vaudio_test.cpp Vaudio_test__ALLcls.cpp Vaudio_test__ALLsup.cpp Vaudio_test__Syms.cpp Vaudio_test__Trace.cpp Vaudio_test__Trace__Slow.cpp   > all.cpp
g++ {flags} all.cpp -o all

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Joseph Shaker
Original Date: 2019-08-07T02:47:57Z


Wilson Snyder wrote:

Maybe your "ar" is broken somehow? Try making a single "g++" command, where the file you specify has an #include of every .cpp file that needs to be compiled.

Verilator has a tool to help

verilator_includer audio_test.cpp Vaudio_test.cpp Vaudio_test__ALLcls.cpp Vaudio_test__ALLsup.cpp Vaudio_test__Syms.cpp Vaudio_test__Trace.cpp Vaudio_test__Trace__Slow.cpp > all.cpp
g++ {flags} all.cpp -o all

Hi, Sorry for the delay!

Neither my linux box nor my mac have

Nonethess, I tried to compile everything manually

with VINC set correctly.

I got tons of ld errors for duplicate symbols, which I guess is better than my ar problem but still not ideal.

duplicate symbol __ZN17Vaudio_test__SymsC2EP11Vaudio_testPKc in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLsup-124ac0.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__Syms-f4f05e.o
duplicate symbol __ZN17Vaudio_test__SymsC1EP11Vaudio_testPKc in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLsup-124ac0.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__Syms-f4f05e.o
duplicate symbol __ZN11Vaudio_test15_ctor_var_resetEv in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test4evalEv in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test5finalEv in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_testD2Ev in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_testD1Ev in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test15_change_requestEP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test18_eval_initial_loopEP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test5_evalEP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test13_eval_initialEP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test12_eval_settleEP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test16_initial__TOP__4EP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test16_sequent__TOP__3EP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test15_settle__TOP__2EP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test14_combo__TOP__1EP17Vaudio_test__Syms in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_testC2EPKc in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_testC1EPKc in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test12__VconfigureEP17Vaudio_test__Symsb in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test-fda4d1.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLcls-fbfbce.o
duplicate symbol __ZN11Vaudio_test8traceChgEP12VerilatedVcdPvj in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLsup-124ac0.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__Trace-c0b37c.o
duplicate symbol __ZN11Vaudio_test12traceChgThisEP17Vaudio_test__SymsP12VerilatedVcdj in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLsup-124ac0.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__Trace-c0b37c.o
duplicate symbol __ZN11Vaudio_test15traceChgThis__4EP17Vaudio_test__SymsP12VerilatedVcdj in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLsup-124ac0.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__Trace-c0b37c.o
duplicate symbol __ZN11Vaudio_test15traceChgThis__3EP17Vaudio_test__SymsP12VerilatedVcdj in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLsup-124ac0.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__Trace-c0b37c.o
duplicate symbol __ZN11Vaudio_test15traceChgThis__2EP17Vaudio_test__SymsP12VerilatedVcdj in:
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__ALLsup-124ac0.o
     /var/folders/wz/97l6sb4x54jd3tsvy3y08qd00000gp/T/Vaudio_test__Trace-c0b37c.o
ld: 24 duplicate symbols for architecture x86_64


</code>

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-08-07T21:23:33Z


The _All files include some of the other files you already have listed, look at the contents to determine which to include and/or diagnose the error messages.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Joseph Shaker
Original Date: 2019-08-08T06:36:12Z


Wilson Snyder wrote:

The _All files include some of the other files you already have listed, look at the contents to determine which to include and/or diagnose the error messages.

Ok, so I finally got this command to work!

g++ audio_test.cpp Vaudio_test__ALLcls.cpp Vaudio_test__ALLsup.cpp  -I$VINC $VINC/verilated.cpp $VINC/verilated_vcd_c.cpp
</code>

I also solved the problem with ar

I used brew to install binutils, which put the gnu version of a in <code>/usr/local/bin/ar</code> . The MACOS default ar lives in ```/usr/bin/ar


When I invoke the mac version explicitly the archive works correctly, so this is possible an error in brew's packaging of gnu binutils.

Would there be a way for now for me to point verilator to a specific version or ar, or make the mac one take precedence? 

I appreciate the help!

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-08-08T08:44:47Z


Glad you solved it.

Verilator uses the make-standard AR variable, so "make AR=foo ..."

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

1 participant