[LLVMdev] Linking Clang with an optional external library

Ryan Govostes
Wed, 14 Nov 2012 08:02:23 -0000

Hi,

I'd like to link Clang against the STP theorem prover. Since Clang is built
by the LLVM build system, I hope this is the correct place to ask for advice.

The attached patch allows me to pass `configure` a --with-stp option and provide
a path to the install prefix for STP. However, I am not familiar with autoconf,
so I am not confident that my changes are the correct way to do this. I would
appreciate feedback on the proposed change.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: with-stp.diff
Type: application/octet-stream
Size: 1490 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20121114/55921a64/attachment.obj>
-------------- next part --------------


Besides the configure.ac changes in the patch, I am unsure of the appropriate
place to add the linker flag. Currently I am simply appending to LDFLAGS in
Clang's tools/driver/Makefile:

+ifdef STP_INSTALL_PREFIX
+LDFLAGS += -L$(STP_INSTALL_PREFIX)/lib -lstp
+endif


To support CMake builds as well, is it sufficient to add the following to
config.h.cmake, and expect the user to pass -DWITH_STP_PREFIX= if they would
like to use this feature?

#cmakedefine STP_C_INTERFACE ${WITH_STP_PREFIX}/include/stp/c_interface.h


One potential issue I noticed in writing this patch is that LLVM's config.h
and Clang's config.h are both #include-guarded by the CONFIG_H macro, and
consequently both cannot be included from the same source file. Perhaps these
should be changed to LLVM_CONFIG_H and CLANG_CONFIG_H, respectively?


Thanks,
Ryan