From 71edda2f1dc226989ba0ef418fdf58f943a729c3 Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Wed, 25 Oct 2023 12:37:46 -0400 Subject: [PATCH 1/9] Report CMAKE_PREFIX_PATH, since the error message with BUILD_TV set can be puzzling if you forget to set this. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72412150e..9cd1fc955 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) From 2287607351ecd401d31963b1a550a67903f4b903 Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Wed, 25 Oct 2023 13:57:30 -0400 Subject: [PATCH 2/9] ReadMe: CMake may look in /opt/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ddd28f75a..18681843e 100644 --- a/README.md +++ b/README.md @@ -307,11 +307,12 @@ should be the only user of this server. Troubleshooting -------- -Some combinations of Clang and MacOS versions may give link warnings +* 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. +or less at the beginning of CMakeLists.txt may work around this. +* CMake may look for configuration information in old installations of LLVM, e.g., under `/opt/`. LLVM Bugs Found by Alive2 -------- From 9f3393c9de2de4870f9e0e025f4b25886eb8a2f3 Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Fri, 27 Oct 2023 18:28:48 -0400 Subject: [PATCH 3/9] Less output for long Lit test `llvm-lit -s` rather than `-vv` for thousands of tests. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 18681843e..b929c7907 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ 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 From 7b4950d93ad0e728094f333f3375b0b277689e20 Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Fri, 27 Oct 2023 18:31:32 -0400 Subject: [PATCH 4/9] Detecting unsound transformations in a local run --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b929c7907..13a87fac9 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,11 @@ $LLVM2_BUILD/bin/llvm-lit -s -Dopt=$ALIVE2_HOME/alive2/build/opt-alive.sh $LLVM2 ``` 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/build/logs/ +``` Running Alive2 as a Clang Plugin From 9c675ac31809f1da772d6546baa63da6dd9bb4cf Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Fri, 27 Oct 2023 18:39:46 -0400 Subject: [PATCH 5/9] README.md CMake advice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the “LLVMConfig.cmake” and “CMAKE_PREFIX_PATH” output. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 13a87fac9..bb61d6c3b 100644 --- a/README.md +++ b/README.md @@ -311,12 +311,12 @@ should be the only user of this server. Troubleshooting -------- +* 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 may look for configuration information in old installations of LLVM, e.g., under `/opt/`. LLVM Bugs Found by Alive2 -------- From dd66222501ee13559857802ed7b0fa70c7d1c24a Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Fri, 27 Oct 2023 19:00:14 -0400 Subject: [PATCH 6/9] Painful lessons trying to build for our 15.0.4 fork MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 805cf71032e00. * 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. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bb61d6c3b..183f03985 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,8 @@ Troubleshooting 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. +* 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 -------- From 4d96737cab87c914181bbb1cf3648da5b1d81faa Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Fri, 27 Oct 2023 19:12:44 -0400 Subject: [PATCH 7/9] 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`. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 183f03985..9d232a96d 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,7 @@ Troubleshooting 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. +* 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`. From 4fd780b5735f23e7c50e58d831a55131bf3af6c2 Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Fri, 27 Oct 2023 20:00:39 -0400 Subject: [PATCH 8/9] ReadMe: Relativize fgrep Relativize fgrep command to ALIVE2_HOME --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d232a96d..28edb6701 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ We run this command on the main LLVM branch each day, and keep track of the resu [here](https://web.ist.utl.pt/nuno.lopes/alive2/). To detect unsound transformations in a local run: ``` -fgrep -r "(unsound)" alive2/build/logs/ +fgrep -r "(unsound)" $ALIVE2_HOME/alive2/build/logs/ ``` From 18cc0a085ab3dade8c04b6ad40ce0cbf3d096b65 Mon Sep 17 00:00:00 2001 From: Flash Sheridan Date: Sat, 28 Oct 2023 11:34:40 -0400 Subject: [PATCH 9/9] Wrap README.md Hard wrap the Troubleshooting section at 79 characters. --- README.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 28edb6701..6e825bede 100644 --- a/README.md +++ b/README.md @@ -311,15 +311,25 @@ should be the only user of this server. Troubleshooting -------- -* 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. +* 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 +[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`. +* 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 --------