panda-planner-dev / pandaPIpgrRepairVerify

BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Problem linking on MacOS #2

Open rpgoldman opened 1 year ago

rpgoldman commented 1 year ago

This issue arose when I worked around #1 as described there. I get this error running make:

[ 55%] Built target to_verifier
[ 60%] Linking CXX executable pandaPIpgrRepairVerify
clang: warning: argument unused during compilation: '-static-libgcc' [-Wunused-command-line-argument]
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [pandaPIpgrRepairVerify] Error 1
make[1]: *** [CMakeFiles/pandaPIpgrRepairVerify.dir/all] Error 2
make: *** [all] Error 2

I am not certain, but I believe that this is because the Makefile is trying to statically link to_verifier, which will not work on the Mac. I tried doing this:

cmake -DBUILD_SHARED_LIBS=ON --trace-expand .

But got the same error.

I looked for the unused argument in the warning and found this:

list(APPEND linker_flags "$<$<CONFIG:RELEASE>:-flto;-static;-static-libgcc>")

Changing that to

list(APPEND linker_flags "$<$<CONFIG:RELEASE>:-flto>")

seems to solve the problem. I don't really understand cmake so I can't fix this myself, but probably the file should be changed to check for MacOS (Darwin?) and choose the linker_flags appropriately.

rpgoldman commented 1 year ago

I believe that a solution is in this patch, but have not tested it.

galvusdamor commented 1 year ago

@rpgoldman Tanks! I don't have a Mac to replicate this. The patch that you provided looks good. The only issue for me was that a pair of braces was missing on the else. I have created another commit for this that fixes the problem and otherwise accepted your patch.

Can you test on your machine whether the code builds now?