iAI icon indicating copy to clipboard operation
iAI copied to clipboard

Phasar does not compile on OS X Big Sur

Open solas opened this issue 4 years ago • 2 comments

  • [x ] I have searched open and closed issues for duplicates
  • [x ] I made sure that I am not using an old project version (DO: pull Phasar, update git submodules, rebuild the project and check if the bug is still there)

Bug description

Phasar does not compile on OS X Big Sur. Following the instructions exactly in the Readme: $ brew install boost $ brew install python3 ... $ cmake -DCMAKE_BUILD_TYPE=Release ..

fails with: lang-12: warning: -Wl,-v: 'linker' input unused [-Wunused-command-line-argument] (in-process) "/usr/local/Cellar/llvm/12.0.1/bin/clang-12" -cc1 -triple x86_64-apple-macosx11.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-rounding-math -munwind-tables -target-sdk-version=11.4 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 650.9 -v -resource-dir /usr/local/Cellar/llvm/12.0.1/lib/clang/12.0.1 -isysroot /Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk -internal-isystem /Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk/usr/local/include -internal-isystem /usr/local/Cellar/llvm/12.0.1/lib/clang/12.0.1/include -internal-externc-isystem /Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk/usr/include -fdebug-compilation-dir /Users/dculbert/Apple/Language/phasar/build/CMakeFiles/CMakeTmp -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -o CMakeFiles/cmTC_bb9f1.dir/CMakeCCompilerABI.c.o -x c /usr/local/Cellar/cmake/3.18.2/share/cmake/Modules/CMakeCCompilerABI.c clang -cc1 version 12.0.1 based upon LLVM 12.0.1 default target x86_64-apple-darwin20.6.0 ignoring nonexistent directory "/Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk/usr/local/include" ignoring nonexistent directory "/Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/llvm/12.0.1/lib/clang/12.0.1/include /Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk/usr/include /Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk/System/Library/Frameworks (framework directory) End of search list. Linking C executable cmTC_bb9f1 /usr/local/Cellar/cmake/3.18.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_bb9f1.dir/link.txt --verbose=1 /usr/local/opt/llvm/bin/clang -isysroot /Applications/Xcode2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_bb9f1.dir/CMakeCCompilerABI.c.o -o cmTC_bb9f1 Homebrew clang version 12.0.1 Target: x86_64-apple-darwin20.6.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin "/usr/bin/ld" -demangle -lto_library /usr/local/Cellar/llvm/12.0.1/lib/libLTO.dylib -dynamic -arch x86_64 -platform_version macos 11.0.0 11.4 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -o cmTC_bb9f1 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_bb9f1.dir/CMakeCCompilerABI.c.o -lSystem /usr/local/Cellar/llvm/12.0.1/lib/clang/12.0.1/lib/darwin/libclang_rt.osx.a @(#)PROGRAM:ld PROJECT:ld64-711 BUILD 15:08:01 Jul 30 2021 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em Library search paths: Framework search paths: ld: library not found for -lSystem clang-12: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [cmTC_bb9f1] Error 1 make: *** [cmTC_bb9f1/fast] Error 2

As one can see, while Cmake has the right basic path to [system wide] frameworks and sdks, its appending non-existent subfolders to that. In addition, while the instruction show how to override (presumably intentionally) standard clang, the linker override spec is not covered.

Context (Environment)

  • phasar: [e895f42fce11d22e1aa2b95bde734e9c3d4878ac]
  • googletest: [commit-id]
  • json: [commit-id]
  • WALi-OpenNWA: [commit-id]

Operating System:

  • [ ] Linux
  • [ ] Windows
  • [ x] macOS

Build Type:

  • [ x] cmake
  • [ ] custom build

Possible solution

We are happy to discuss possible solutions to this problem, especially if it origniates from a design flaw.

Example files

Files:

solas avatar Sep 17 '21 18:09 solas

While I haven't successfully run Phasar yet, I did get it to build on OS X. There were at least 3 changes:

  1. exported CFLAGS and CXXFLAGS must include a -I<Path to actual system includes> , e.g. to stdio.h. The brew LLVM and clang install as used in the build instructions doesn't have any
  2. exported SDKROOT must be set to reference the same system sdk (e.g. path to sdk within Xcode), to help the linker
  3. modern clang doesn't have a std++fs library anymore. I changed your CMakeFile.txt to:
  • set(PHASAR_STD_FILESYSTEM stdc++fs)
  • set(PHASAR_STD_FILESYSTEM stdc++)

solas avatar Sep 21 '21 18:09 solas

I work on macOS Monterey. I seem to partially get phasar built and currently can use phasar-llvm to generate call-graph for a module. Since I haven't intensively use&test phasar, I can't guarantee that I get it absolutely right. But the following is at least sth. I do to make phasar built&run:

  1. I configure all set(PHASAR_STD_FILESYSTEM xxx) to set(PHASAR_STD_FILESYSTEM stdc++), (without a deep understanding of stdc++, c++fs, stdc++fs) since linker complains about not finding c++fs&stdc++fs.
  2. It seems that LLVM doesn't like certain self defined target. In my case I find gtest&gtest_main cause the problem. So I choose to comment out add_subdirectory(external/googletest EXCLUDE_FROM_ALL) and pass -DPHASAR_BUILD_UNITTESTS=OFF to cmake, because a hacky way to get it rolling as fast as possible without unittest is ok for me.

Hope that help anybody encountering build problem. And I will be very glad if anybody can inform me of any mistakes I make, or give more insights into the build problem :-)

c2hpxq avatar Nov 26 '21 02:11 c2hpxq

Hi @solas @c2hpxq , what is the current state of the issue? Are you able to build phasar in the meanwhile? We are already working on Conan support, which hopefully also eases building phasar for you.

MMory avatar Dec 01 '22 13:12 MMory

Closing this for now due to inactivity. In the meanwhile the cmake stuff has been improved here and there. Please reach out again if you encounter build issues in the future.

MMory avatar Mar 02 '23 15:03 MMory