Homebrew-core: brew install llvm --HEAD fails

Created on 16 Feb 2017  Â·  19Comments  Â·  Source: Homebrew/homebrew-core

  • [x] Ran brew update and retried your prior step?
  • [x] Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • [x] Confirmed this is problem with specific formulae and not Homebrew/brew? If it's a general Homebrew/brew problem please file this issue at https://github.com/Homebrew/brew/issues/new

Bug reports:

brew install llvm -- HEAD does not succeed. It still fails if the --without-compiler-rt flag is passed too.

brew gist-logs llvm
https://gist.github.com/7a0d759815d6c8dd969fdd98fc3a5d78

brew config:

OMEBREW_VERSION: 1.1.10
ORIGIN: https://github.com/Homebrew/brew
HEAD: 69d1cedd12d37d6a9535fbba17d2129b165c08f8
Last commit: 12 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 5c583c0177929689b44928af8a99e96b27404c84
Core tap last commit: 11 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.0.0-p648
Clang: 8.0 build 800
Git: 2.10.1 => /Library/Developer/CommandLineTools/usr/bin/git
Perl: /usr/local/bin/perl => /usr/local/Cellar/perl/5.24.0_1/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.4.0/bin/ruby
Java: N/A
macOS: 10.12.3-x86_64
Xcode: N/A
CLT: 8.2.0.0.1.1480973914
X11: N/A
upstream issue

Most helpful comment

@fish2000 please try this:

diff --git a/Formula/llvm.rb b/Formula/llvm.rb
index 103aa3ba4d..2e5e5dcaab 100644
--- a/Formula/llvm.rb
+++ b/Formula/llvm.rb
@@ -175,6 +175,12 @@ class Llvm < Formula
     (buildpath/"tools/lld").install resource("lld")
     (buildpath/"tools/polly").install resource("polly")

+    if build.head?
+      inreplace "projects/openmp/libomptarget/CMakeLists.txt",
+        "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports",
+        "-Wl,-undefined,dynamic_lookup"
+    end
+
     if build.with? "lldb"
       if build.with? "python"
         pyhome = `python-config --prefix`.chomp

All 19 comments

This is reproducible. The failure is

[ 54%] Built target libomp-needed-headers
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f projects/openmp/runtime/src/CMakeFiles/omp.dir/build.make projects/openmp/runtime/src/CMakeFiles/omp.dir/depend
cd /tmp/llvm-20170216-22015-1uahg6 && /usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_depends "Unix Makefiles" /tmp/llvm-20170216-22015-1de71hz /tmp/llvm-20170216-22015-1de71hz/projects/openmp/runtime/src /tmp/llvm-20170216-22015-1uahg6 /tmp/llvm-20170216-22015-1uahg6/projects/openmp/runtime/src /tmp/llvm-20170216-22015-1uahg6/projects/openmp/runtime/src/CMakeFiles/omp.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f projects/openmp/runtime/src/CMakeFiles/omp.dir/build.make projects/openmp/runtime/src/CMakeFiles/omp.dir/build
make[2]: Nothing to be done for `projects/openmp/runtime/src/CMakeFiles/omp.dir/build'.
[ 54%] Built target omp
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f projects/openmp/libomptarget/CMakeFiles/omptarget.dir/build.make projects/openmp/libomptarget/CMakeFiles/omptarget.dir/depend
cd /tmp/llvm-20170216-22015-1uahg6 && /usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_depends "Unix Makefiles" /tmp/llvm-20170216-22015-1de71hz /tmp/llvm-20170216-22015-1de71hz/projects/openmp/libomptarget /tmp/llvm-20170216-22015-1uahg6 /tmp/llvm-20170216-22015-1uahg6/projects/openmp/libomptarget /tmp/llvm-20170216-22015-1uahg6/projects/openmp/libomptarget/CMakeFiles/omptarget.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f projects/openmp/libomptarget/CMakeFiles/omptarget.dir/build.make projects/openmp/libomptarget/CMakeFiles/omptarget.dir/build
[ 54%] Linking CXX shared library ../../../lib/libomptarget.dylib
cd /tmp/llvm-20170216-22015-1uahg6/projects/openmp/libomptarget && /usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_link_script CMakeFiles/omptarget.dir/link.txt --verbose=1
/usr/local/Homebrew/Library/Homebrew/shims/super/clang++   -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=date-time -std=c++11 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.11 -dynamiclib -Wl,-headerpad_max_install_names  -stdlib=libc++ -o ../../../lib/libomptarget.dylib -install_name /tmp/llvm-20170216-22015-1uahg6/lib/libomptarget.dylib CMakeFiles/omptarget.dir/src/omptarget.cpp.o -ldl -Wl,--version-script=/tmp/llvm-20170216-22015-1de71hz/projects/openmp/libomptarget/exports 
ld: unknown option: --version-script=/tmp/llvm-20170216-22015-1de71hz/projects/openmp/libomptarget/exports
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libomptarget.dylib] Error 1
make[1]: *** [projects/openmp/libomptarget/CMakeFiles/omptarget.dir/all] Error 2
make: *** [all] Error 2

The bug needs to be reported upstream to llvm: http://bugs.llvm.org/

Closing this since we don't actually provide support for head builds.

I have attempted to report this issue upstream – I sent this to [email protected]:

Hi, I don’t have an account on bugs.llvm.org – I am just trying to comment on Bug #31919 (http://bugs.llvm.org/show_bug.cgi?id=31919) which has kept me, along with many other Mac Homebrew users (e.g. https://github.com/Homebrew/homebrew-core/issues/10017#issuecomment-280280682), from being able to build LLVM from HEAD for a few months now. I’m just trying to contribute the errors from my own experience with this bug (which, FWIW, are more or less the same as those posted by the original reporter of #31919: the “--version-script” flag causes the linker to fail while trying to link the library ../../../lib/libomptarget.dylib).

I’ll happily personally report and work on this issue if that would help; in this case, I would need an account on bugs.llvm.org. But if it’s simpler not to grant me access, just passing along the fact that this issue is still a showstopper for Homebrew users to the relevant LLVM committers will work also.

In any case, I love LLVM and I appreciate everyones’ hard work on it! Cheers,

-Alex

… I haven’t been able to build LLVM from HEAD for at least the last month because of this bug – if anyone can either report it more reliably to those upstream, or suggest a workaround, I’m into it.

We could probably filter out --version-script= in superenv, but they should knock that off.

From cmake/modules/HandleLLVMOptions.cmake

if(WIN32)
  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
  if(CYGWIN)
    set(LLVM_ON_WIN32 0)
    set(LLVM_ON_UNIX 1)
  else(CYGWIN)
    set(LLVM_ON_WIN32 1)
    set(LLVM_ON_UNIX 0)
  endif(CYGWIN)
else(WIN32)
  if(UNIX)
    set(LLVM_ON_WIN32 0)
    set(LLVM_ON_UNIX 1)
    if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
      set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
    else()
      set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
    endif()
  else(UNIX)
    MESSAGE(SEND_ERROR "Unable to determine platform")
  endif(UNIX)
endif(WIN32)

So they're trying to do the right thing, but something is getting messed up.

@ilovezfs I heartily agree; personally I am way too low on the FLOSS totem pole to get the attention of the upstream committers.

It’s a linker flag that is specified to clang with -Wl,<…> which hopefully wouldn’t complicate such a patch; would it be straightforward to update superenv as you suggest, if I may ask? I have written the occasional formula update but I’m not Ruby-ish enough to mess with such a fundamental part of Homebrew.

Do you mind trying this stupid patch:

diff --git a/Formula/llvm.rb b/Formula/llvm.rb
index 103aa3b..c381d29 100644
--- a/Formula/llvm.rb
+++ b/Formula/llvm.rb
@@ -164,6 +164,12 @@ class Llvm < Formula
   end

   def install
+    if build.head?
+      inreplace "cmake/modules/HandleLLVMOptions.cmake",
+        "set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)",
+        "set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)"
+    end
+
     # Apple's libstdc++ is too old to build LLVM
     ENV.libcxx if ENV.compiler == :clang

@ilovezfs not at all, I was just trying some far stupider tweaks in llvm.rb. Will attempt this now.

@ilovezfs no change with your inreplace patch – the flag is still there, causing the same error, in the same place:

[  8%] Linking CXX shared library ../../../lib/libomptarget.dylib
cd /tmp/llvm-20170302-19979-1kvaykp/projects/openmp/libomptarget && /usr/local/Cellar/cmake/3.8.0-rc1/bin/cmake -E cmake_link_script CMakeFiles/omptarget.dir/link.txt --verbose=1
/usr/local/Homebrew/Library/Homebrew/shims/super/clang++  -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=date-time -std=c++11 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.12 -dynamiclib -Wl,-headerpad_max_install_names  -stdlib=libc++ -o ../../../lib/libomptarget.dylib -install_name /tmp/llvm-20170302-19979-1kvaykp/lib/libomptarget.dylib CMakeFiles/omptarget.dir/src/omptarget.cpp.o -ldl -Wl,--version-script=/tmp/llvm-20170302-19979-blz250/projects/openmp/libomptarget/exports 
[  8%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ScaledNumber.cpp.o
cd /tmp/llvm-20170302-19979-1kvaykp/lib/Support && /usr/local/Homebrew/Library/Homebrew/shims/super/clang++  -DLLVM_BUILD_GLOBAL_ISEL -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/tmp/llvm-20170302-19979-1kvaykp/lib/Support -I/tmp/llvm-20170302-19979-blz250/lib/Support -I/tmp/llvm-20170302-19979-1kvaykp/include -I/tmp/llvm-20170302-19979-blz250/include  -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=date-time -std=c++11 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.12     -o CMakeFiles/LLVMSupport.dir/ScaledNumber.cpp.o -c /tmp/llvm-20170302-19979-blz250/lib/Support/ScaledNumber.cpp
ld: unknown option: --version-script=/tmp/llvm-20170302-19979-blz250/projects/openmp/libomptarget/exports
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libomptarget.dylib] Error 1
make[1]: *** [projects/openmp/libomptarget/CMakeFiles/omptarget.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Fun times. OK, I'll dig deeper.

@ilovezfs it’s confusing, as the LLVM_HAVE_LINK_VERSION_SCRIPT cmake variable is set elsewhere with differing criteria e.g. https://llvm.org/svn/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake:

if (LLVM_ON_UNIX AND NOT APPLE)
  set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
else()
  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
endif()

@ilovezfs I appreciate it. If you have any other patches, send them on and I’ll try them.

@fish2000 please try this:

diff --git a/Formula/llvm.rb b/Formula/llvm.rb
index 103aa3ba4d..2e5e5dcaab 100644
--- a/Formula/llvm.rb
+++ b/Formula/llvm.rb
@@ -175,6 +175,12 @@ class Llvm < Formula
     (buildpath/"tools/lld").install resource("lld")
     (buildpath/"tools/polly").install resource("polly")

+    if build.head?
+      inreplace "projects/openmp/libomptarget/CMakeLists.txt",
+        "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports",
+        "-Wl,-undefined,dynamic_lookup"
+    end
+
     if build.with? "lldb"
       if build.with? "python"
         pyhome = `python-config --prefix`.chomp

@ilovezfs wow, so far so good on this one – the build has past the problematic libomp.dylib bit and is 20% into things. Will report back in however many wallclock seconds it takes to finish, indeed!

Good.

_SUCCESS_

screen shot 2017-03-02 at 11 20 03 am

… options used were --HEAD --with-python --with-graphviz; I will attempt to rebuild with ocaml support and lldb later on (like whenever it feels like my terminal window isn’t festooned with enough compile traces)

Thank you super muchly @ilovezfs for addressing the issue – especially as the ball wasn’t anywhere in the Homebrew court in this case… but so with the latest LLVM I can now resume hacking on halide again, yes!

Also @ilovezfs – in your professional opinion, is this inreplace-ing of linker args indicative of a pattern that can/should be codified in the superenv shim (as you mentioned initially) or is this just, like, a one-off?

No, this shouldn't be in superenv. It's an upstream bug in http://llvm.org/git/openmp.git where they're not guarding the use of --version-script= in the same way they are everywhere else.

Thank you super muchly @ilovezfs for addressing the issue – especially as the ball wasn’t anywhere in the Homebrew court in this case… but so with the latest LLVM I can now resume hacking on halide again, yes!

You're welcome.

@ilovezfs PS, I broke out the changes to the LLVM formula, per our earlier troubleshooting session, into a patch file.

Since implementing these changes of yours, I have rebuilt LLVM three times since with the modified formula in place. I checked – as best as I was capable of discerning – and it seems that the upstream bug remains unfixed in the OpenMP module’s repo. So: for me, this patch has remained quite handy; maybe it can help others too. Share and Enjoy!

Was this page helpful?
0 / 5 - 0 ratings