Rewrite configure, adding --with-so support#61
Conversation
`extra-libraries` is configured via the `configure` script. Also configuring it in `libclang-bindings.cabal` results in *two* `-lclang` options being passed. It should not be configured in `libclang-bindings.cabal`, so this commit removes that configuration.
00e7962 to
f2ad3a2
Compare
|
Note that this PR does not compare LLVM/Clang versions. Here are the versions involved:
Another complication is that versions retrieved from |
|
@edsko asked me to document configuration in the Configuring This package is configured using an In general, If The Note that this symbolic link must be persistent, the path is cached in the Cabal store and used whenever a package that (transitively) depends on If you upgrade LLVM/Clang, you must reconfigure and rebuild all packages that depend on it. When using the |
4550e12 to
43ee779
Compare
When in the same project, Cabal runs the `configure` script for *both* the library and `clang-bootstrap`, in parallel, even when `clang-bootstrap` is not built! This results in duplicate `configure` output. This can be avoided by moving `clang-bootstrap` into a separate project. This also allows us to remove the `dev` flag.
The `--with-so` argument allows users to specify the path to a shared library file, used to determine `extra-libraries` and `extra-lib-dirs` on Linux systems. It is used to work around Cabal linking issues. When `--with-so` is specified, `extra-lib-dirs` might be configured with two library directories: the directory of the specified file and the library directory determined using `clang-config` or `LLVM_PATH` (when different). This necessitates different logic for calculating `LDFLAGS`, so the organization of the script is changed to enable this. This reorganization puts related things together, IMHO making the script easier to understand/maintain. All internal variables are renamed to use a (`wt_`) prefix, as is documented as best practice when using `autoconf`, since substitutions are now defined close to where the variables are defined. Note that `extra-lib-dirs` is now dynamic. It is determined by users when using `--with-so` and defaults to `clang` when `--with-so` is not used. We need to fix the Nix implementation to work with this. I found the `clang_isBeforeInTranslationUnit` check was broken. This commit reverts to using `AC_CONFIG_HEADERS` to fix it.
This was accidentally set to a non-existing tag, likely a tag for a different project. This commit changes to a tag in this project, which we should update during each release.
4f13ae5 to
18e852c
Compare
|
I added release process documentation: rendered. Feel free to adjust as needed. BTW, we used package name The only thing that is still inconsistent is the name of the repository: |
|
This is not an issue on Windows, as Windows DLL versions are not managed like they are on Linux. We always link to I am not sure about macOS. Perhaps it is possible to have this issue when the following conditions are met:
IMHO we should worry about this only if it comes up. In that case, I can easily add a (separate!)
|
|
@travis and I workshopped the docs a bit; it's going to leave in a Configuring
|
The parser is implemented using an M4 macro and POSIX shell so that we can parse both the llvm-config and libclang versions (and check that they match). Note that the implementation was surprisingly difficult and frustrating, as many things (such as much more concise implementations in `awk` or `egrep`) worked on the command-line but would not work in the configure script, likely due to standards compliance. This is fragile, so changing it should be done with extreme caution. Perhaps we can use Cabal Hooks and avoid the configure script at some point in the future... The configure script creates a new `libclang_version.h` header that defines `LIBCLANG_VERSION_MAJOR`, `LIBCLANG_VERSION_MINOR`, and `LIBCLANG_VERSION_PATCH` macros, as well as a GHC-style `MIN_VERSION_LIBCLANG` macro. Note that these macros reflect the version of `libclang` used at compile-time, *not* the version of `libclang` that is loaded at runtime.
More detail is provided, including examples.
f49d04e to
3265589
Compare
3265589 to
a7fdbd3
Compare
58fa545 to
72e40c1
Compare
4e19ec2 to
b331a8d
Compare
The module now exports the version strings as well as the parsed versions of the compile-time and runtime `libclang` versions, making it very easy to work with them consistently.
This commit adds a manual. IMHO it is small enough to be a single-page manual, which has better usability than multiple-page manuals. Note that the `libclang-bindings` package should have a README because it will be displayed on Hackage.
b331a8d to
672628e
Compare
Link definition syntax is changed from `[text]: <target>` to `[text]: target` for consistency with the new manual conventions.
See well-typed/hs-bindgen#1923 for details.
The
--with-soargument allows users to specify the path to a shared library file, used to determineextra-librariesandextra-lib-dirson Linux systems. It is used to work around Cabal linking issues.When
--with-sois specified,extra-lib-dirsmight be configured with two library directories: the directory of the specified file and the library directory determined usingclang-configorLLVM_PATH(when different). This necessitates different logic for calculatingLDFLAGS, so the organization of the script is changed to enable this. This reorganization puts related things together, IMHO making the script easier to understand/maintain. All internal variables are renamed to use a (wt_) prefix, as is documented as best practice when usingautoconf, since substitutions are now defined close to where the variables are defined.Note that
extra-lib-dirsis now dynamic. It is determined by users when using--with-soand defaults toclangwhen--with-sois not used. We need to update the Nix implementation to work with this.I found the
clang_isBeforeInTranslationUnitcheck was broken. This commit reverts to usingAC_CONFIG_HEADERSto fix it.This PR also moves
clang-bootstrapinto separate project.When in the same project, Cabal runs the
configurescript for both the library andclang-bootstrap, in parallel, even whenclang-bootstrapis not built! This results in duplicateconfigureoutput. This can be avoided by movingclang-bootstrapinto a separate project. This also allows us to remove thedevflag.