[MacPorts] #68329: py311-scipy @1.10.1_0+gfortran+openblas not building on Sonoma apple silicon
MacPorts
noreply at macports.org
Sat Oct 21 00:34:35 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):
@cjones051073 comment:13
> I do not believe the `duplicate LC_RPATH` messages are the real issue
here. They are just warnings, so whilst something we may need to clean up
ourselves (assuming GCC upstream doesn't do something to prevent them) I
think for now we ignore them.
I’m not so sure. They’re not warnings, they’re the source of linker
failures. Observe:
{{{
mark at arm-and-hammer zsh% cat main.c
int main(int argc, char * argv[]) { return 0; }
mark at arm-and-hammer zsh% otool -l /opt/local/lib/libopenblas.dylib| grep
-B1 -A2 LC_RPATH
Load command 15
cmd LC_RPATH
cmdsize 40
path /opt/local/lib/libgcc (offset 12)
Load command 16
cmd LC_RPATH
cmdsize 40
path /opt/local/lib/libgcc (offset 12)
Load command 17
cmd LC_RPATH
cmdsize 32
path @loader_path (offset 12)
Load command 18
cmd LC_RPATH
cmdsize 32
path /opt/local/lib (offset 12)
Load command 19
cmd LC_RPATH
cmdsize 72
path /opt/local/lib/gcc13/gcc/arm64-apple-darwin23/13.2.0 (offset
12)
Load command 20
cmd LC_RPATH
cmdsize 40
path /opt/local/lib/gcc13 (offset 12)
mark at arm-and-hammer zsh% clang main.c -L/opt/local/lib -lopenblas && echo
succeeded || echo failed
ld: duplicate LC_RPATH '/opt/local/lib/libgcc' in
'/opt/local/lib/libopenblas-r1.dylib'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
failed
}}}
But if the duplicate `LC_RPATH` is removed, the link succeeds:
{{{
mark at arm-and-hammer zsh% cp /opt/local/lib/libopenblas.dylib .
mark at arm-and-hammer zsh% install_name_tool -delete_rpath
/opt/local/lib/libgcc libopenblas.dylib
mark at arm-and-hammer zsh% otool -l libopenblas.dylib | grep -B1 -A2
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)
mark at arm-and-hammer zsh% clang main.c -L. -lopenblas && echo succeeded ||
echo failed
succeeded
}}}
You may think that this isn’t compelling enough, in case
`install_name_tool` might be doing something else to the module. (It does,
it makes changes in the `__LINKEDIT` segment.) So also consider:
{{{
mark at arm-and-hammer zsh% python3
Python 3.11.6 (main, Oct 6 2023, 10:09:23) [Clang 15.0.0
(clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> b = bytearray(open('/opt/local/lib/libopenblas.dylib', 'rb').read())
>>> path = b'/opt/local/lib/libgcc'
>>> b[b.find(path, b.find(path) + 1) + len(path) - 1] += 1
>>> open('libopenblas.dylib', 'wb').write(b)
13067496
>>> exit()
mark at arm-and-hammer zsh% otool -l libopenblas.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 40
path /opt/local/lib/libgcd (offset 12)
Load command 17
cmd LC_RPATH
cmdsize 32
path @loader_path (offset 12)
Load command 18
cmd LC_RPATH
cmdsize 32
path /opt/local/lib (offset 12)
Load command 19
cmd LC_RPATH
cmdsize 72
path /opt/local/lib/gcc13/gcc/arm64-apple-darwin23/13.2.0 (offset
12)
Load command 20
cmd LC_RPATH
cmdsize 40
path /opt/local/lib/gcc13 (offset 12)
mark at arm-and-hammer zsh% clang main.c -L. -lopenblas && echo succeeded ||
echo failed
succeeded
}}}
An “easy” workaround for this would be to run `install_name_tool
-delete_rpath` on `libopenblas.dylib`. But it would be better to find
where the duplicate is coming from in the first place, and fix that.
--
Ticket URL: <https://trac.macports.org/ticket/68329#comment:14>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list