[MacPorts] #68329: py311-scipy @1.10.1_0+gfortran+openblas not building on Sonoma apple silicon

MacPorts noreply at macports.org
Sat Oct 21 04:34:04 UTC 2023


#68329: py311-scipy @1.10.1_0+gfortran+openblas not building on Sonoma apple
silicon
--------------------------+-----------------------
  Reporter:  quintusdias  |      Owner:  michaelld
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.8.1
Resolution:               |   Keywords:
      Port:  py311-scipy  |
--------------------------+-----------------------

Comment (by markmentovai):

 `ld-classic`, which [https://github.com/macports/macports-
 ports/blob/52644490bc16f5608787b02e88a1db49f2a9a100/lang/gcc13/Portfile#L174
 MacPorts gcc is configured to use] on macOS ≥ 14 with Xcode ≥ 15, says
 that it’s ignoring the duplicate `-rpath`, but it actually isn’t.

 {{{
 mark at arm-and-hammer zsh% cat lib.c
 void LibFunc() {}
 mark at arm-and-hammer zsh% clang -c lib.c -o lib.o
 mark at arm-and-hammer zsh% ld-classic -dylib lib.o -o liblib.dylib -L$(xcrun
 --show-sdk-path)/usr/lib -lSystem -rpath /opt/local/lib/libgcc -rpath
 /opt/local/lib/libgcc
 ld: warning: duplicate -rpath '/opt/local/lib/libgcc' ignored
 mark at arm-and-hammer zsh% otool -l liblib.dylib | grep -B 1 -A 2 LC_RPATH
 Load command 11
           cmd LC_RPATH
       cmdsize 24
          path /opt/local/lib/libgcc (offset 12)
 Load command 12
           cmd LC_RPATH
       cmdsize 24
          path /opt/local/lib/libgcc (offset 12)
 }}}

 Compared to `ld` (not `-classic`), which says that it’s ignoring the
 duplicate and then actually ignores the duplicate.

 {{{
 mark at arm-and-hammer zsh% ld -dylib lib.o -o liblib.dylib -L$(xcrun --show-
 sdk-path)/usr/lib -lSystem -rpath /opt/local/lib/libgcc -rpath
 /opt/local/lib/libgcc
 ld: warning: duplicate -rpath '/opt/local/lib/libgcc' ignored
 mark at arm-and-hammer zsh% otool -l liblib.dylib | grep -B 1 -A 2 LC_RPATH
 Load command 11
           cmd LC_RPATH
       cmdsize 24
          path /opt/local/lib/libgcc (offset 12)
 }}}

 When driven by, say, `gcc-mp-13`, the compiler driver inserts its own
 `-rpath /opt/local/lib/libgcc`. This is in addition to the `-rpath
 /opt/local/lib/libgcc` that it inserts when directed to do so by the
 OpenBLAS build, which specifies `-Wl,-rpath,/opt/local/lib/libgcc`.

 {{{
 mark at arm-and-hammer zsh% diff -U7 \
     <(gcc-mp-13 -dynamiclib lib.o -o liblib.dylib -v 2>&1 | grep collect2
 | tr ' ' '\n') \
     <(gcc-mp-13 -dynamiclib lib.o -o liblib.dylib -rpath
 /opt/local/lib/libgcc -v 2>&1 | grep collect2 | tr ' ' '\n')
 --- /dev/fd/11  2023-10-21 00:17:58
 +++ /dev/fd/12  2023-10-21 00:17:58
 @@ -11,14 +11,16 @@
  0.0
  -o
  liblib.dylib
  -L/opt/local/lib/gcc13/gcc/arm64-apple-darwin23/13.2.0
  -L/opt/local/lib/gcc13/gcc/arm64-apple-darwin23/13.2.0/../../..
  lib.o
  -dylib
 +-rpath
 +/opt/local/lib/libgcc
  -lemutls_w
  -lgcc
  -lSystem
  -lgcc
  -no_compact_unwind
  -rpath
  /opt/local/lib/libgcc
 }}}

 The extra `-rpath` in the OpenBLAS build is coming from
 [https://github.com/macports/macports-
 ports/blob/bdf6a2f79691eee44bfd93f31efb048241cfc36d/_resources/port1.0/group/compilers-1.0.tcl#L841
 PortGroup compilers 1.0]. This appears to be incorrect for the macOS ≥ 14,
 Xcode ≥ 15 combination. When I remove that locally and build OpenBLAS, I
 wind up with:

 {{{
 mark at arm-and-hammer zsh% otool -l
 /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/OpenBLAS-0.3.24/libopenblas-r1.dylib
 | grep -B 1 -A 2 LC_RPATH
 Load command 15
           cmd LC_RPATH
       cmdsize 40
          path /opt/local/lib/libgcc (offset 12)
 Load command 16
           cmd LC_RPATH
       cmdsize 32
          path @loader_path (offset 12)
 Load command 17
           cmd LC_RPATH
       cmdsize 32
          path /opt/local/lib (offset 12)
 Load command 18
           cmd LC_RPATH
       cmdsize 72
          path /opt/local/lib/gcc13/gcc/arm64-apple-darwin23/13.2.0 (offset
 12)
 Load command 19
           cmd LC_RPATH
       cmdsize 40
          path /opt/local/lib/gcc13 (offset 12)
 }}}

 This is positive, but then the OpenBLAS build doesn’t complete because
 another portion of it uses clang, which doesn’t know anything about the
 libgcc `-rpath`.

 So perhaps the solution is to patch MacPorts gcc to handle this situation,
 to go along with the `--with-darwin-extra-rpath` patch, since that’s
 really the underlying cause: if a single `-Wl,-rpath` matching the
 `--with-darwin-extra-rpath` is found, let the first one ride and omit the
 rest.

-- 
Ticket URL: <https://trac.macports.org/ticket/68329#comment:17>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list