zetzit / zz

🍺🐙 ZetZ a zymbolic verifier and tranzpiler to bare metal C
MIT License
1.6k stars 52 forks source link

Add suppport for manual specification of compile flags etc. #21

Closed fogti closed 4 years ago

fogti commented 4 years ago

I haven't found documentation about this (I haven't looked at the code, yet). It would be nice to specify the additional CFLAGS and LDFLAGS either via zz.toml (this is kinda undocumented) and via environment variables (this is currently missing).

Use case: I have a "semi-broken" clang install, which requires additional linker flags/libraries to successfully link. Otherwise, it errors out with something like the following:

/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/llvm/9/bin/../../../../lib/clang/9.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_unwind_linux_libcdep.cc.o): in function `__sanitizer::Unwind_GetIP(_Unwind_Context*)':
(.text+0x1): undefined reference to `_Unwind_GetIP'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/llvm/9/bin/../../../../lib/clang/9.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_unwind_linux_libcdep.cc.o): in function `__sanitizer::Unwind_Trace(_Unwind_Context*, void*)':
(.text+0x28): undefined reference to `_Unwind_GetIP'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/llvm/9/bin/../../../../lib/clang/9.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_unwind_linux_libcdep.cc.o): in function `__sanitizer::BufferedStackTrace::UnwindSlow(unsigned long, unsigned int)':
(.text+0xdf): undefined reference to `_Unwind_Backtrace'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/llvm/9/bin/../../../../lib/clang/9.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_unwind_linux_libcdep.cc.o): in function `__sanitizer::BufferedStackTrace::UnwindSlow(unsigned long, void*, unsigned int)':
(.text+0x2cd): undefined reference to `_Unwind_Backtrace'
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

(missing library would be probably -lunwind in this case).

aep commented 4 years ago

Hi.

zz.toml has both lflags and cflags.

I believe env variables are missing tho, will have to add those. They'd also fit your use case better because they're standard

aep commented 4 years ago

could you try if PR #23 suits your use case?

fogti commented 4 years ago

It fixes my use case.

(Now the hello example links successfully, but fails with a SIGSEGV at runtime...)

aep commented 4 years ago

great, please open a new bug for the segfault and try to attach as much info as possible.