Menu

#775 Missing LDFLAGS in vlnggen

v1.0 (example)
open-fixed
None
5
2026-06-12
2025-04-12
No

Hi,

I'm on a M4 Mac, and I need custom LDFLAGS to find the verilator and systemc libraries.

I was unable to link, but changing
shell g++ --shared $v_objs $v_lib -pthread -lpthread -o $soname

to

shell g++ $LDFLAGS --shared $v_objs $v_lib -pthread -lpthread -o $soname

Fixed the problem.

Discussion

  • Giles Atkinson

    Giles Atkinson - 2025-04-12

    Interesting, what did you need to add? It has been building for some time on M1 here without problems. (A sub-build of "Build others".) I would add this, but LDFLAGS seems too generic and liable to use a value set for something else. .IVLNG_LDFLAGS perhaps?

    Edit: my mistake, that is for Icarus, not Verilator. While the Verilator support was tested on Mac, that was using X86.

     

    Last edit: Giles Atkinson 2025-04-13
  • Carsten Wulff

    Carsten Wulff - 2025-04-13

    Seems like it was only this part of my LDFLAGS that was necessary to get the script to work

    export LDFLAGS=" -undefined dynamic_lookup ${LDFLAGS}"

     
  • Giles Atkinson

    Giles Atkinson - 2025-04-13
    • status: open --> open-accepted
    • assigned_to: Giles Atkinson
     
  • Giles Atkinson

    Giles Atkinson - 2025-04-13

    Strange, there should be no undefined symbols in the library. But I think I have seen something similar before.

    I am inclined to fix this by including that option in the script, but would first like to know more. Without the option, what is the error message?

    Thanks, G.

     
  • Holger Vogt

    Holger Vogt - 2025-04-13

    I have just compiled pre-master-45, using script compile_macos_clang_M2.sh, on a mac mini, M2, Sonoma 14.5 (23F79), without any problem.

     
  • Giles Atkinson

    Giles Atkinson - 2025-04-13

    The problem occurred in the script, vlnggen, so the way to reproduce this is to try an example circuit in examples/xspice/verilator.

    G.

     
  • Carsten Wulff

    Carsten Wulff - 2025-04-13

    Rather long log, so adding as attachment

     
  • ponzu840w

    ponzu840w - 2026-06-07

    Verilator declares sc_time_stamp() as a weak symbol. It means the user may optionally define it. Linux ld tolerates a missing weak symbol, macOS ld doesn't. The shim (verilator_shim.cpp) never actually calls sc_time_stamp() (time is driven via VerilatedContext::time()), so adding an empty stub there (attached patch) satisfies macOS ld without any vlnggen change.

     
  • Giles Atkinson

    Giles Atkinson - 2026-06-07

    Does the original suggestion of adding a linker option work for you? It is in the parallel ghnggen script, and seems harmless there.

     
  • ponzu840w

    ponzu840w - 2026-06-08

    The linker option approach works for me too. My patch was an attempt to address the problem without touching linker options, but if ghnggen already handles it that way, doing the same in vlnggen seems fine. I didn't know about ghnggen.

     
  • Giles Atkinson

    Giles Atkinson - 2026-06-11

    Thank you for testing. In fact the Verilator documentation does mention this issue (in the FAQ!) and recommends " -CFLAGS -DVL_TIME_CONTEXT". That will be in the update, as it solves the same problem on Windows, What I do not understand, is why this issue did not show up in initial testing of Verilator integration. The weak symbol was introduced in 2021, two years earlier.

     
  • Giles Atkinson

    Giles Atkinson - 2026-06-12
    • status: open-accepted --> open-fixed
     
  • Giles Atkinson

    Giles Atkinson - 2026-06-12

    Fix committed as [1ff2ae].

     

    Related

    Commit: [1ff2ae]


Log in to post a comment.