Skip to content

Commit

Permalink
Friendlier CMake output and ReadMe tips (AliveToolkit#949)
Browse files Browse the repository at this point in the history
* Report CMAKE_PREFIX_PATH, since the error message
with BUILD_TV set can be puzzling if you forget to set this.

* ReadMe:  CMake may look in /opt/

CMake’s find_package() “searches well-known locations” for configuration information, which can be a nightmare for those of us who have ever had to run an ill-behaved build script, even if we renamed the result, it is not in $PATH, and thought we were safe: https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html#using-pre-built-packages-with-find-package

* Less output for long Lit test

`llvm-lit -s` rather than `-vv` for thousands of tests.

* Detecting unsound transformations in a local run

* README.md CMake advice

Check the “LLVMConfig.cmake” and “CMAKE_PREFIX_PATH” output.

* Painful lessons trying to build for our 15.0.4 fork

* Tightly coupled to LLVM top of tree source:  E.g., the source ca. 15.0.7 was broken for our 15.0.4 fork, due to LLVM f09cf34d00 moving Triple.h ⇒ Alive2 805cf71.
* Experiment with Clang versions and vendors: I couldn’t compile alive2/ir/memory.h:90 with Homebrew Clang 16.0.5, but (surprisingly) could with Apple clang-1400.0.29.202, which is normally worse on open source projects.  This may have been LLVM bug 32386.

* Troubleshooting tip about `BUILD_SHARED_LIBS`

Troubleshooting tip about `BUILD_SHARED_LIBS` with `USEDLIBS` and `LLVMLIBS` and perhaps `dd_llvm_target`.  The first two are from https://llvm.org/docs/Projects.html#variables-for-building-programs. I got further, but not far enough, in linking when I supplemented `dd_llvm_target` with conditional `link_libraries`.
  • Loading branch information
FlashSheridan authored Oct 29, 2023
1 parent 8771c44 commit e031ebd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ if (BUILD_LLVM_UTILS OR BUILD_TV)
find_package(LLVM REQUIRED CONFIG)

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

if (NOT LLVM_ENABLE_RTTI)
Expand Down
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ To run translation validation on all the LLVM unit tests for IR-level
transformations:

```
$LLVM2_BUILD/bin/llvm-lit -vv -Dopt=$ALIVE2_HOME/alive2/build/opt-alive.sh $LLVM2_HOME/llvm/test/Transforms
$LLVM2_BUILD/bin/llvm-lit -s -Dopt=$ALIVE2_HOME/alive2/build/opt-alive.sh $LLVM2_HOME/llvm/test/Transforms
```

We run this command on the main LLVM branch each day, and keep track of the results
[here](https://web.ist.utl.pt/nuno.lopes/alive2/).
[here](https://web.ist.utl.pt/nuno.lopes/alive2/). To detect unsound transformations in a local run:

```
fgrep -r "(unsound)" $ALIVE2_HOME/alive2/build/logs/
```


Running Alive2 as a Clang Plugin
Expand Down Expand Up @@ -307,11 +311,25 @@ should be the only user of this server.

Troubleshooting
--------
Some combinations of Clang and MacOS versions may give link warnings
* Check the “LLVMConfig.cmake” and “CMAKE_PREFIX_PATH” output from CMake in
case of build problems. CMake may look for configuration information in old
installations of LLVM, e.g., under `/opt/`, if these are not set properly.
* Some combinations of Clang and MacOS versions may give link warnings
“-undefined dynamic_lookup may not work with chained fixups,” and
runtime errors with “symbol not found in flat namespace.” Setting
[CMAKE_OSX_DEPLOYMENT_TARGET](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html) as a cache entry to 11.0
or less at the beginning of CMakeLists.txt may work around this.
[CMAKE_OSX_DEPLOYMENT_TARGET](https://cmake.org/cmake/help/latest/variable/
CMAKE_OSX_DEPLOYMENT_TARGET.html) as a cache entry to 11.0
or less at the beginning of CMakeLists.txt may work around this.
* Building for Translation Validation requires enabling `BUILD_SHARED_LIBS`.
For LLVM forks not normally built with the option, this may interfere with
CMake files’ use of `USEDLIBS` and `LLVMLIBS` and perhaps `dd_llvm_target`.
* Building for Translation Validation is tightly coupled to LLVM top of tree
source. Building a fork with older source may require reverting to the
corresponding Alive2 commit. This in turn may require experimentation with
Clang versions and vendors.
* Building older source on an up-to-date machine may require adjustments. For
example, the now-deleted file `scripts/rewritepass.py` depended on the
deprecated Python 2; update the shebang line to `python3`.

LLVM Bugs Found by Alive2
--------
Expand Down

0 comments on commit e031ebd

Please sign in to comment.