Opened 13 years ago

Closed 13 years ago

#32507 closed defect (fixed)

net-snmp-config should not include -arch flags

Reported by: jeremyhu (Jeremy Huddleston Sequoia) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.0.3
Keywords: Cc:
Port: net-snmp

Description

If perl5.12 is built +universal, then sane-backends will fail to build unless it is also built universal. This is because sane-backends queries perl to figure out what LDFLAGS to use. These LDFLAGS will include '-arch i386 -arch x86_64' even though sane-backends is only being built for x86_64.

This build failure will look like this to the user because libusb will not be universal:

checking usb.h presence... yes
checking for usb.h... yes
checking for usb_interrupt_read in -lusb... no
configure: error: USB support requested but required libraries not found.
shell command " cd "/opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_graphics_sane-backends/sane-backends/work/sane-backends-1.0.22" && ./configure --prefix=/opt/local --mandir=/opt/local/share/man --with-docdir=/opt/local/share/doc/sane-backends --enable-local-backends --enable-libusb --disable-latex --without-gphoto2 " returned error 1
Error: Target org.macports.configure returned: configure failure: shell command failed (see log for details)
Warning: the following items did not execute (for sane-backends): org.macports.install org.macports.configure org.macports.build org.macports.destroot
Log for sane-backends is at: /opt/local/var/macports/logs/_Users_jeremy_src_macports_trunk_dports_graphics_sane-backends/sane-backends/main.log
Error: Unable to upgrade port: 1
To report a bug, see <http://guide.macports.org/#project.tickets>

config.log shows the real cause:

configure:9640: checking for usb_interrupt_read in -lusb
configure:9665: /Developer/usr/bin/clang -o conftest -pipe -O2 -arch x86_64 -W -Wall -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -pipe -O2 -Udarwin11 -Ddarwin11=darwin11 -pipe -O2 -arch i386 -fno-common -DPERL_DARWIN -I/opt/local/include -no-cpp-precomp -fno-strict-aliasing -fstack-protector -I/opt/local/include -I/opt/local/lib/perl5/5.12.3/darwin-multi-2level/CORE -I/opt/local/include -I/opt/local/include -I. -I/opt/local/include -I/opt/local/include -no-cpp-precomp -fno-common -include sys/types.h -D_REENTRANT -L/opt/local/lib -arch x86_64 conftest.c -lusb   -Wl,-framework,CoreFoundation -Wl,-framework,IOKit -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -lnetsnmp -lcrypto >&5
clang: warning: argument unused during compilation: '-no-cpp-precomp'
clang: warning: argument unused during compilation: '-no-cpp-precomp'
ld: warning: ignoring file /opt/local/lib/libusb.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
  "_usb_interrupt_read", referenced from:
      _main in cc-BlaEF1.o

Change History (6)

comment:1 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Owner: changed from aguynamedryan+sane@… to ryandesign@…
Port: net-snmp added; sane-backends removed
Summary: sane-backends-1.0.22 fails to build if archs don't match perl5.12net-snmp-config should not include -arch flags

It's coming from net-snmp-config:

$ net-snmp-config --cflags
-DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -pipe -O2 -Udarwin11 -Ddarwin11=darwin11 -pipe -O2 -arch i386 -fno-common -DPERL_DARWIN -I/opt/local/include -no-cpp-precomp -fno-strict-aliasing -fstack-protector -I/opt/local/include -I/opt/local/lib/perl5/5.12.3/darwin-multi-2level/CORE -I/opt/local/include -I/opt/local/include -I. -I/opt/local/include

comment:2 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Interestingly, net-snmp is a fat binary:

$ file /opt/local/lib/libnetsnmp.dylib
/opt/local/lib/libnetsnmp.dylib: Mach-O universal binary with 2 architectures
/opt/local/lib/libnetsnmp.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
/opt/local/lib/libnetsnmp.dylib (for architecture i386):	Mach-O dynamically linked shared library i386

but it was not installed fat: net-snmp-5.7.1_0.darwin_11.x86_64.tbz2

This explains why just the -arch x86_64 was stripped from net-snmp-config with this hunk in the Portfile:

reinplace "s|${my_archflags}||g" ${worksrcpath}/${name}-config

So the problem is that net-snmp is actually building fat even though it's not requested to. I believe this is because perl5.12 is actually fat, and net-snmp is using perl5's CFLAGS

comment:3 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

It looks like ${prefix}/bin/net-snmp-create-v3-user may also need similar cleanup:

net-snmp-create-v3-user:NSC_LDFLAGS="-L/opt/local/lib -L/opt/local/lib -arch x86_64 -arch i386"

comment:4 in reply to:  2 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to jeremyhu@…:

So the problem is that net-snmp is actually building fat even though it's not requested to. I believe this is because perl5.12 is actually fat, and net-snmp is using perl5's CFLAGS

Then this is #24779. I wish somebody would resolve it.

comment:5 Changed 13 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Ugg. I can't believe that bug is so old. It's an obvious fix too...

comment:6 in reply to:  3 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: newclosed

Replying to jeremyhu@…:

It looks like ${prefix}/bin/net-snmp-create-v3-user may also need similar cleanup:

r87908.

Note: See TracTickets for help on using tickets.