[MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
---------------------+-----------------------
 Reporter:  kencu    |      Owner:
     Type:  defect   |     Status:  new
 Priority:  Normal   |  Milestone:
Component:  ports    |    Version:
 Keywords:  powerpc  |       Port:  clang-3.8
---------------------+-----------------------
 During the build of clang-3.8 on 10.5 PPC, the following error is noted:

 {{{
 [ 14%] Generating
 ../../../../lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a
 cd
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/projects
 /compiler-rt/lib/builtins && /opt/local/bin/cmake -E make_directory
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/./lib/clang/3.8.1/lib/darwin
 cd
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/projects
 /compiler-rt/lib/builtins && lipo -output
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/./lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a
 -create -arch i386
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_i386_10.4.a
 -arch x86_64
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_x86_64_10.4.a
 fatal error: lipo: specifed architecture type (i386) for file
 (/opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_i386_10.4.a)
 does not match its cputype (18) and cpusubtype (0) (should be cputype (7)
 and cpusubtype (3))
 }}}

 This appears to be due to an error in the cmake build script for this
 library. See below for more analysis and a workaround that allows the
 build to succeed.

--
Ticket URL: <https://trac.macports.org/ticket/54242>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+---------------------
  Reporter:  kencu      |      Owner:
      Type:  defect     |     Status:  new
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+---------------------

Comment (by kencu):

 During configuration, this is noted:
 {{{
 CMake Warning at projects/compiler-
 rt/cmake/Modules/CompilerRTDarwinUtils.cmake:33 (message):
   Detecting supported architectures from 'ld -v' failed.  Returning
 default
   set.
 Call Stack (most recent call first):
   projects/compiler-rt/cmake/config-ix.cmake:347
 (darwin_get_toolchain_supported_archs)
   projects/compiler-rt/CMakeLists.txt:206 (include)


 -- Toolchain supported arches: i386;x86_64;ppc;ppc64;armv7;armv7s;arm64
 -- Finding valid architectures for osx...
 -- OSX supported arches:
 -- Finding valid architectures for 10.4...
 -- OSX 10.4 supported arches: i386;x86_64;ppc;ppc64
 -- Compiler-RT supported architectures:
 CMake Warning at projects/compiler-
 rt/cmake/Modules/CompilerRTDarwinUtils.cmake:216 (message):
   Not generating lipo target for clang_rt.cc_kext because no input
 libraries
   exist.
 Call Stack (most recent call first):
   projects/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake:334
 (darwin_lipo_libs)
   projects/compiler-rt/lib/builtins/CMakeLists.txt:364
 (darwin_add_builtin_libraries)


 CMake Warning at projects/compiler-
 rt/cmake/Modules/CompilerRTDarwinUtils.cmake:216 (message):
   Not generating lipo target for clang_rt.osx because no input libraries
   exist.
 }}}

 And this generated file from cmake: `./build/projects/compiler-
 rt/lib/builtins/CMakeFiles/clang_rt.10.4.dir/build.make` contains
 references to i386 and x86_64:
 {{{
 lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a:
 lib/libclang_rt.builtins_i386_10.4.a
 lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a:
 lib/libclang_rt.builtins_x86_64_10.4.a
         @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue
 --bold --progress-
 dir=/opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/CMakeFiles
 --progress-num=$(CMAKE_PROGRESS_1) "Generating
 ../../../../lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a"
         cd
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/projects
 /compiler-rt/lib/builtins && /opt/local/bin/cmake -E make_directory
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/./lib/clang/3.8.1/lib/darwin
         cd
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/projects
 /compiler-rt/lib/builtins && lipo -output
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/./lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a
 -create -arch i386
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_i386_10.4.a
 -arch x86_64
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_x86_64_10.4.a
 }}}
 which leads to the failure line noted above.

 The first issue is that both of the generated libclang_rt.builtins* files
 are ppc (neither is ppc64), but that's not too important as for now we're
 only after ppc anyway.
 {{{
 $ cd `port work clang-3.8`
 $ lipo -info ./build/lib/libclang_rt.builtins_i386_10.4.a
 input file ./build/lib/libclang_rt.builtins_i386_10.4.a is not a fat file
 Non-fat file: ./build/lib/libclang_rt.builtins_i386_10.4.a is
 architecture: ppc
 $ lipo -info ./build/lib/libclang_rt.builtins_x86_64_10.4.a
 input file ./build/lib/libclang_rt.builtins_x86_64_10.4.a is not a fat
 file
 Non-fat file: ./build/lib/libclang_rt.builtins_x86_64_10.4.a is
 architecture: ppc
 }}}

 The second issue is that the -arch for the
 libclang_rt.builtins_i386_10.4.a has to be `ppc`.

 To generate the libclang_rt.builtins library for ppc, edit the
 `./build/projects/compiler-
 rt/lib/builtins/CMakeFiles/clang_rt.10.4.dir/build.make`

 and change this line:
 {{{
 cd
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/projects
 /compiler-rt/lib/builtins && lipo -output
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/./lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a
 -create -arch i386
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_i386_10.4.a
 -arch x86_64
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_x86_64_10.4.a
 }}}

 to this, updating the arch type (leave the name alone, although it's
 incorrect), and deleting the second arch (as it is also ppc):
 {{{
 cd
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/projects
 /compiler-rt/lib/builtins && lipo -output
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/./lib/clang/3.8.1/lib/darwin/libclang_rt.10.4.a
 -create -arch ppc
 /opt/local/var/macports/build/_opt_LeopardPorts_lang_llvm-3.8/clang-3.8/work/build/lib/libclang_rt.builtins_i386_10.4.a
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/54242#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
In reply to this post by MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+----------------------
  Reporter:  kencu      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+----------------------
Changes (by mf2k):

 * cc: jeremyhu (removed)
 * cc: larryv (added)
 * status:  new => assigned
 * owner:   => jeremyhu


--
Ticket URL: <https://trac.macports.org/ticket/54242#comment:2>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
In reply to this post by MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+----------------------
  Reporter:  kencu      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+----------------------

Comment (by kencu):

 The cmake logic in this file appears to contain the relevant code:

 {{{
 work/llvm-3.8.1.src/projects/compiler-rt/cmake/config-ix.cmake
 }}}
 and checks for the 10.4 RT arches like this:
 {{{

   # Figure out which arches to use for each OS
   darwin_get_toolchain_supported_archs(toolchain_arches)
   message(STATUS "Toolchain supported arches: ${toolchain_arches}")


  # Need to build a 10.4 compatible libclang_rt
     set(DARWIN_10.4_SYSROOT ${DARWIN_osx_SYSROOT})
     set(DARWIN_10.4_BUILTIN_MIN_VER 10.4)
     set(DARWIN_10.4_BUILTIN_MIN_VER_FLAG
         -mmacosx-version-min=${DARWIN_10.4_BUILTIN_MIN_VER})
     set(DARWIN_10.4_SKIP_CC_KEXT On)
     darwin_test_archs(10.4
       DARWIN_10.4_ARCHS
       ${toolchain_arches})
     message(STATUS "OSX 10.4 supported arches: ${DARWIN_10.4_ARCHS}")
     if(DARWIN_10.4_ARCHS)
       # don't include the Haswell slice in the 10.4 compatibility library
       list(REMOVE_ITEM DARWIN_10.4_ARCHS x86_64h)
       list(APPEND BUILTIN_SUPPORTED_OS 10.4)
     endif()
 }}}

 which calls darwin_get_toolchain_supported_archs which is in this file

 {{{
 work/llvm-3.8.1.src/projects/compiler-
 rt/cmake/Modules/CompilerRTDarwinUtils.cmake
 }}}

 {{{
 function(darwin_get_toolchain_supported_archs output_var)
   execute_process(
     COMMAND ld -v
     ERROR_VARIABLE LINKER_VERSION)

   string(REGEX MATCH "configured to support archs: ([^\n]+)"
          ARCHES_MATCHED "${LINKER_VERSION}")
   if(ARCHES_MATCHED)
     set(ARCHES "${CMAKE_MATCH_1}")
     message(STATUS "Got ld supported ARCHES: ${ARCHES}")
     string(REPLACE " " ";" ARCHES ${ARCHES})
   else()
     # If auto-detecting fails, fall back to a default set
     message(WARNING "Detecting supported architectures from 'ld -v'
 failed. Returning default set.")
     set(ARCHES "i386;x86_64;armv7;armv7s;arm64")
   endif()

   set(${output_var} ${ARCHES} PARENT_SCOPE)
 endfunction()
 }}}

 on 10.5 INTEL the `ld` test gives you proper archs:
 {{{
  ld -v
 @(#)PROGRAM:ld  PROJECT:ld64-127.2
 configured to support archs: i386 x86_64 ppc ppc64 armv6 armv7
 LTO support using: LLVM version 3.3
 }}}

 but on on 10.5 PPC you get this:
 {{{
 $ ld -v
 @(#)PROGRAM:ld  PROJECT:ld64-127.2
 LLVM version 3.3
 }}}

 so it goes to the defaults instead
 {{{

     set(ARCHES "i386;x86_64;armv7;armv7s;arm64")
 }}}
 which are wrong for ppc. I generated a simple patch to allowed that test
 to return:
 {{{
     set(ARCHES "i386;x86_64;ppc;ppc64;armv7;armv7s;arm64")
 }}}
 and I had hoped that might solve this error, but as you can see from the
 configuration listing above, even though it now returns the proper ARCHES
 from the `ld` test, the error still occurs, so the incorrect arch setting
 must be elsewhere.

--
Ticket URL: <https://trac.macports.org/ticket/54242#comment:3>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
In reply to this post by MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+----------------------
  Reporter:  kencu      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+----------------------

Comment (by kencu):

 I think this file `work/llvm-4.0.0.src/projects/compiler-
 rt/cmake/Modules/CompilerRTDarwinUtils.cmake` is missing most of the logic
 to support `ppc` and `ppc64` archs, in the end. There are other functions
 in that file that done have ppc support. It doesn't look like a lot to
 add, but it would take a little logic to work out.

 I suppose it's kind of surprising then that the default build comes out
 with a ppc arch library that we can use at all.

 I don't think it's easy to patch files _after_ the configure stage. Some
 reinplacing could be done post-configure instead, I suppose.

 I wish it was a bit easier to debug cmake build scripts.

--
Ticket URL: <https://trac.macports.org/ticket/54242#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
In reply to this post by MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+----------------------
  Reporter:  kencu      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+----------------------

Comment (by kencu):

 I've been working further on this as time allows. The cmake script that
 manages the building of libclang_rt.10.4.a looks at the supported arches
 to test
 {{{
 -- OSX 10.4 supported arches: i386;x86_64;ppc;ppc64
 }}}
 and then tries to run a test-compile with each using the build system.
 This build of clang-3.8 on 10.5 PPC is bootstrapping with gcc6 (no other
 choice). So with this gcc6 macports configuration, all the x86 code fails
 to build, and the system tries to build the ppc and ppc64 code. But all
 these test compiles fail to build as well for some reason (Cmake error log
 attached), so I guess it defaults to i386 and x86_64. And herein comes the
 "lucky" quirk - when gcc6 on ppc gets asked to build -arch i386, it says
 it can't and then builds it -arch ppc instead. So that is how we wind up
 getting code out.

 The supplied object files that make libclang_rt.10.4.a are close to
 correct, but they don't actually include the proper ppc ASM code from the
 ppc folder -- the system builds the i386 folder instead, as it is
 confused.

 With that, it's perhaps surprising that in the end, this produces a build
 system that passes 487/500 tests in the test-suite. (10 of those the
 broken exceptions on ppc).

 To fix this issue, the easiest thing to do would be to skip the tricky and
 multi-arch cmake build tricks used in compiler_rt and just write up a
 cmake build file by hand. This turned out to be trivial (attached), but I
 need to make sure I have all the proper objects included and none of the
 not-needed ones, and this is not so trivial. Any help there appreciated.

 Alternatively, it is likely possible to see why all the gcc ppc cmake
 build tests are failing, and fix that. No doubt this is the proper thing
 to do, and wish that I could do that.

 Finally, it might be possible to build clang_rt as a separate project
 using the makefiles as per the old days -- it is designed to do that as a
 separate build I see.

 Pretty close. clang-3.8 on PPC is working surprisingly well to build
 software that can't be built any other way, in the end.

--
Ticket URL: <https://trac.macports.org/ticket/54242#comment:5>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
In reply to this post by MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+----------------------
  Reporter:  kencu      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+----------------------
Changes (by kencu):

 * Attachment "clang_rt on PPC fails to configure -- CMakeError.log" added.

 error log when cmake tries to test-compile ppc code during configuration

--
Ticket URL: <https://trac.macports.org/ticket/54242>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
In reply to this post by MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+----------------------
  Reporter:  kencu      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+----------------------
Changes (by kencu):

 * Attachment "proj-compilerrt-lib-builtins- alternate incomplete
 CMakeLists.txt" added.

 alternate cmake build script for compiler_rt-lib-builtins that builds
 single-arch library

--
Ticket URL: <https://trac.macports.org/ticket/54242>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed architecture in libclang_rt.10.4.a does not match its cputype -- and workaround that allows build to succeed

MacPorts
In reply to this post by MacPorts
#54242: clang-3.8 build fails on 10.5 PPC due to fatal error: lipo: specifed
architecture in libclang_rt.10.4.a does not match its cputype -- and
workaround that allows build to succeed
------------------------+----------------------
  Reporter:  kencu      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:  powerpc
      Port:  clang-3.8  |
------------------------+----------------------
Changes (by kencu):

 * Attachment "error in clang-3.8 cmake configure" added.

 error noted during configuration of clang-3.8

--
Ticket URL: <https://trac.macports.org/ticket/54242>
MacPorts <https://www.macports.org/>
Ports system for macOS
Loading...