Bug 242053

Summary: devel/binutils 2.33.1 Failed build: ld: error: undefined symbol: bswap_identity_64
Product: Ports & Packages Reporter: Martin Filla <freebsd>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Many People CC: bapt, cryx-freebsd, dewayne, dim, eadler, freebsd, jeroen.pulles, koobs, mazhe, mrT1188123, nimaje+fbz, rhurlin, robbak, saper
Priority: --- Keywords: needs-qa
Version: LatestFlags: bugzilla: maintainer-feedback? (bapt)
dim: merge-quarterly+
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
config.log
none
Replace problematic inline functions with macros
none
fixed from upstream koobs: maintainer-approval+

Description Martin Filla 2019-11-18 10:21:57 UTC
Hi, 
i compiled binutils with portmaster on FreeBSD 12.1-RELEASE
but i have problem with linker.

v -f $depbase.Tpo $depbase.Po
depbase=`echo od-xcoff.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
cc -DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./../bfd -I./../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -isystem /usr/local/include -I/usr/local/include -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow  -pipe  -g -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -MT od-xcoff.o -MD -MP -MF $depbase.Tpo -c -o od-xcoff.o od-xcoff.c &&\
mv -f $depbase.Tpo $depbase.Po
/bin/sh ./libtool  --tag=CC   --mode=link cc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow  -pipe  -g -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -fstack-protector-strong  -o objdump objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o rdcoff.o bucomm.o version.o filemode.o elfcomm.o od-xcoff.o ../opcodes/libopcodes.la ../libctf/libctf.a ../bfd/libbfd.la ../libiberty/libiberty.a /usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib
libtool: link: cc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -pipe -g -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -fstack-protector-strong -o objdump objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o rdcoff.o bucomm.o version.o filemode.o elfcomm.o od-xcoff.o /usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib  ../opcodes/.libs/libopcodes.a -L/usr/local/lib ../libctf/libctf.a ../bfd/.libs/libbfd.a -lz ../libiberty/libiberty.a
ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:112
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:113
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:114
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:125
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:134
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:147
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:167
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:168
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:175
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:187
>>>               ctf-archive.o:(ctf_arc_write) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:266
>>>               ctf-archive.o:(arc_write_one_ctf) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:299
>>>               ctf-archive.o:(sort_modent_by_name) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:300
>>>               ctf-archive.o:(sort_modent_by_name) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:322
>>>               ctf-archive.o:(ctf_arc_bufopen) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:359
>>>               ctf-archive.o:(ctf_arc_open_internal) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:431
>>>               ctf-archive.o:(ctf_arc_open_by_name_internal) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:432
>>>               ctf-archive.o:(ctf_arc_open_by_name_internal) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:446
>>>               ctf-archive.o:(ctf_arc_open_by_name_internal) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:543
>>>               ctf-archive.o:(ctf_archive_raw_iter_internal) in archive ../libctf/libctf.a

ld: error: undefined symbol: bswap_identity_64
>>> referenced by ctf-archive.c:545
>>>               ctf-archive.o:(ctf_archive_raw_iter_internal) in archive ../libctf/libctf.a

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[6]: *** [Makefile:922: objdump] Error 1
gmake[6]: Leaving directory '/usr/ports/devel/binutils/work-native/binutils-2.33.1/binutils'
gmake[5]: *** [Makefile:1130: all-recursive] Error 1
gmake[5]: Leaving directory '/usr/ports/devel/binutils/work-native/binutils-2.33.1/binutils'
gmake[4]: *** [Makefile:757: all] Error 2
gmake[4]: Leaving directory '/usr/ports/devel/binutils/work-native/binutils-2.33.1/binutils'
gmake[3]: *** [Makefile:3612: all-binutils] Error 2
gmake[3]: Leaving directory '/usr/ports/devel/binutils/work-native/binutils-2.33.1'
gmake[2]: *** [Makefile:851: all] Error 2
gmake[2]: Leaving directory '/usr/ports/devel/binutils/work-native/binutils-2.33.1'
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/devel/binutils
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/binutils

===>>> make build failed for devel/binutils
===>>> Aborting update

===>>> Update for devel/binutils failed
===>>> Aborting update
Comment 1 Martin Filla 2019-11-22 13:52:10 UTC
Created attachment 209338 [details]
config.log

config.log from compilation devel/binutils
Comment 2 Matthieu Volat 2019-11-24 08:59:37 UTC
Created attachment 209378 [details]
Replace problematic inline functions with macros

Hi, I've the same issue.

It seems to originate from some inlined (byte swapping) function declared in a header file that are never used so pruned from object files, but still expected at a link step.

Un-inlining is not really an option as it create multiple reference, I guess this could be worked around with the static keyword but I also managed to workaround this using preprocessor macros instead... I've attach a patch if that can be a temporary fix for some people.
Comment 3 Baptiste Daroussin freebsd_committer 2019-12-16 08:24:21 UTC
can you try the following patch from upstream?

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=patch;h=cbbbc402e059ee345cb781d3ceb757ae1cc679ee
Comment 4 Dimitry Andric freebsd_committer 2019-12-16 17:04:56 UTC
(In reply to Baptiste Daroussin from comment #3)
Yes, that should be much better.  In C, *never* use "naked" inline functions!
Comment 5 Baptiste Daroussin freebsd_committer 2019-12-16 18:44:24 UTC
Created attachment 209997 [details]
fixed from upstream
Comment 6 Baptiste Daroussin freebsd_committer 2019-12-16 18:45:53 UTC
I added actually a full fix, sent by the upstream developper who claim to be responsible for the issue. he has been nice enough to sent me a full chunk patch which can apply straight on the ports tree!

Please confirm that is fixes the issue for you
Comment 7 Eitan Adler freebsd_committer freebsd_triage 2019-12-26 12:57:47 UTC
Apologies about the delay. binutils successfully compiles with this patch.
Comment 8 Marcin Cieślak 2020-01-11 15:45:04 UTC
Ran into this today with poudriere. Can we get this patch committed?
Comment 9 Marcin Cieślak 2020-01-11 19:26:33 UTC
Another data point: this happens only under WITH_DEBUG=true
Comment 10 Kubilay Kocak freebsd_committer freebsd_triage 2020-01-25 13:15:43 UTC
@Bapt Upstream patch has been tested and confirmed, comment 7 and comment 8, along with people on IRC. 

Would you like me to reset Assignee so someone else can take care of it?
Comment 11 Kubilay Kocak freebsd_committer freebsd_triage 2020-01-28 03:10:38 UTC
Comment on attachment 209997 [details]
fixed from upstream

Approved by: portmgr (maintainer timeout: > 1 month)

Pending QA
Comment 12 Kubilay Kocak freebsd_committer freebsd_triage 2020-01-28 03:12:09 UTC
^Triage: Assignee timeout, open to take

attachment 209997 [details] has been tested/verified, but needs QA (poudriere) testing.
Comment 13 dewayne 2020-01-28 03:42:17 UTC
(In reply to Marcin Cieślak from comment #9)
Thanks Marcin, I've been running with binutils 2.33.1,1 since late December on both i386 and amd64 FreeBSD 12.1S and couldn't understand why I don't have the problem (???).  However I do have
DEBUG_FLAGS=
WITHOUT_DEBUG=true
WITHOUT_DEBUG_FILES=YES
sprinkled around.
Comment 14 Marcin Cieślak 2020-01-31 15:22:35 UTC
Dewayne, I think my build breaks because I was using lower compiler optimization level as implied by WITH_DEBUG=yes. It might work well during the "normal" build.
Comment 15 freebsd 2020-02-16 19:49:40 UTC
Is this the same issue? Only on FreeBSD 12.1-p2 amd64 (Poudriere):

https://pastebin.pl/view/652f7bb1

First and Last lines from Poudriere build:

=>> Building devel/binutils
build started at Sun Feb 16 20:29:34 CET 2020
port directory: /usr/ports/devel/binutils
package name: binutils-2.33.1_2,1
building for: FreeBSD Ben-FreeBSD12amd64-default-job-01 12.1-RELEASE-p2 FreeBSD 12.1-RELEASE-p2 amd64
maintained by: bapt@FreeBSD.org
Makefile ident:      $FreeBSD: head/devel/binutils/Makefile 525129 2020-02-04 08:38:59Z manu $
Poudriere version: 3.3.99.20191210
Host OSVERSION: 1201000
Jail OSVERSION: 1201000
Job Id: 01

---Begin Environment---
SHELL=/bin/csh
OSVERSION=1201000
UNAME_v=FreeBSD 12.1-RELEASE-p2
UNAME_r=12.1-RELEASE-p2
BLOCKSIZE=K
MAIL=/var/mail/root
STATUS=1
HOME=/root
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
LOCALBASE=/usr/local
USER=root
LIBEXECPREFIX=/usr/local/libexec/poudriere
POUDRIERE_VERSION=3.3.99.20191210
MASTERMNT=/usr/local/poudriere/data/.m/Ben-FreeBSD12amd64-default/ref
POUDRIERE_BUILD_TYPE=bulk
PACKAGE_BUILDING=yes
SAVED_TERM=screen
PWD=/usr/local/poudriere/data/.m/Ben-FreeBSD12amd64-default/ref/.p/pool
P_PORTS_FEATURES=FLAVORS SELECTED_OPTIONS
MASTERNAME=Ben-FreeBSD12amd64-default
SCRIPTPREFIX=/usr/local/share/poudriere
OLDPWD=/usr/local/poudriere/data/.m/Ben-FreeBSD12amd64-default/ref/.p
SCRIPTPATH=/usr/local/share/poudriere/bulk.sh
POUDRIEREPATH=/usr/local/bin/poudriere
---End Environment---

---Begin Poudriere Port Flags/Env---
PORT_FLAGS=
PKGENV=
FLAVOR=native
DEPENDS_ARGS=
MAKE_ARGS= FLAVOR=native
---End Poudriere Port Flags/Env---

---Begin OPTIONS List---
===> The following configuration options are available for binutils-2.33.1_2,1:
     NLS=on: Native Language Support
     RELRO=off: enable -z relro in ELF linker by default
     STATIC=off: Build static executables and/or libraries
===> Use 'make config' to modify these settings
---End OPTIONS List---

--MAINTAINER--
bapt@FreeBSD.org
--End MAINTAINER--

--CONFIGURE_ARGS--
--with-system-zlib  --with-gmp=/usr/local  --with-mpfr=/usr/local  --enable-targets=all  --enable-threads=yes --disable-werror  --enable-deterministic-archives  --with-sysroot=/  --enable-x86-relax-relocations=no --enable-nls --enable-relro=no --enable-gold --enable-plugins --prefix=/usr/local ${_LATE_CONFIGURE_ARGS}
--End CONFIGURE_ARGS--

--CONFIGURE_ENV--
MAKE=gmake XDG_DATA_HOME=/wrkdirs/usr/ports/devel/binutils/work-native  XDG_CONFIG_HOME=/wrkdirs/usr/ports/devel/binutils/work-native  HOME=/wrkdirs/usr/ports/devel/binutils/work-native TMPDIR="/tmp" PATH=/wrkdirs/usr/ports/devel/binutils/work-native/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin SHELL=/bin/sh CONFIG_SHELL=/bin/sh CMAKE_PREFIX_PATH="/usr/local" CONFIG_SITE=/usr/ports/Templates/config.site lt_cv_sys_max_cmd_len=262144
--End CONFIGURE_ENV--

--MAKE_ENV--
ac_cv_func_sbrk=0 XDG_DATA_HOME=/wrkdirs/usr/ports/devel/binutils/work-native  XDG_CONFIG_HOME=/wrkdirs/usr/ports/devel/binutils/work-native  HOME=/wrkdirs/usr/ports/devel/binutils/work-native TMPDIR="/tmp" PATH=/wrkdirs/usr/ports/devel/binutils/work-native/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  CC="clang" CFLAGS="-O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing "  CPP="clang-cpp" CPPFLAGS="-isystem /usr/local/include"  LDFLAGS=" -fstack-protector-strong " LIBS="-L/usr/local/lib"  CXX="clang++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -Wno-c++11-narrowing -isystem /usr/local/include "  MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444"
--End MAKE_ENV--

--PLIST_SUB--
 NLS="" NO_NLS="@comment " RELRO="@comment " NO_RELRO="" STATIC="@comment " NO_STATIC="" GOLD="" OSREL=12.1 PREFIX=%D LOCALBASE=/usr/local  RESETPREFIX=/usr/local LIB32DIR=lib DOCSDIR="share/doc/binutils"  EXAMPLESDIR="share/examples/binutils"  DATADIR="share/binutils"  WWWDIR="www/binutils"  ETCDIR="etc/binutils"
--End PLIST_SUB--

--SUB_LIST--
 NLS="" NO_NLS="@comment " RELRO="@comment " NO_RELRO="" STATIC="@comment " NO_STATIC="" PREFIX=/usr/local LOCALBASE=/usr/local  DATADIR=/usr/local/share/binutils DOCSDIR=/usr/local/share/doc/binutils EXAMPLESDIR=/usr/local/share/examples/binutils  WWWDIR=/usr/local/www/binutils ETCDIR=/usr/local/etc/binutils
--End SUB_LIST--

---Begin make.conf---
USE_PACKAGE_DEPENDS=yes
BATCH=yes
WRKDIRPREFIX=/wrkdirs
PORTSDIR=/usr/ports
PACKAGES=/packages
DISTDIR=/distfiles
FORCE_PACKAGE=yes
PACKAGE_BUILDING=yes
PACKAGE_BUILDING_FLAVORS=yes
#### /usr/local/etc/poudriere.d/Ben-FreeBSD12amd64-make.conf ####
USE_PACKAGE_DEPENDS=yes
BATCH=yes
WRKDIRPREFIX=/wrkdirs

OPTIONS_UNSET=X11

WITH_PKGNG=yes

CC=clang
CXX=clang++
CPP=clang-cpp

#DEFAULT_VERSIONS=  perl5=5.28 python=2.7 python2=2.7 php=72 apache=2.6 mysql=56 ssl=openssl
#DEFAULT_VERSIONS=  perl5=5.30 python=2.7 python2=2.7 php=73 apache=2.6 mysql=56 ssl=openssl
DEFAULT_VERSIONS=  perl5=5.30 python=3.6 python3=3.6 php=73 apache=2.6 mysql=56 ssl=openssl

WITH_SSP_PORTS=yes

SENDMAIL_CF_DIR= /usr/local/share/sendmail/cf
WITH_CCACHE_BUILD=yes

# aanzetten voor bijv. DCC
DISABLE_LICENSES=yes
WITH_CCACHE_BUILD=yes
CCACHE_DIR=/root/.ccache
#### /usr/ports/Mk/Scripts/ports_env.sh ####
_CCVERSION_00792546=FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1) Target: x86_64-unknown-freebsd12.1 Thread model: posix InstalledDir: /usr/bin
_ALTCCVERSION_00792546=none
_CXXINTERNAL_bf0c4528=FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1) Target: x86_64-unknown-freebsd12.1 Thread model: posix InstalledDir: /usr/bin "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld-elf.so.1" "--hash-style=both" "--enable-new-dtags" "-o" "a.out" "/usr/lib/crt1.o" "/usr/lib/crti.o" "/usr/lib/crtbegin.o" "-L/usr/lib" "/dev/null" "-lc++" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/crtend.o" "/usr/lib/crtn.o"
CC_OUTPUT_00792546_58173849=yes
CC_OUTPUT_00792546_9bdba57c=yes
CC_OUTPUT_00792546_6a4fe7f5=yes
CC_OUTPUT_00792546_6bcac02b=yes
CC_OUTPUT_00792546_67d20829=yes
CC_OUTPUT_00792546_bfa62e83=yes
CC_OUTPUT_00792546_f0b4d593=yes
CC_OUTPUT_00792546_308abb44=yes
CC_OUTPUT_00792546_f00456e5=yes
CC_OUTPUT_00792546_65ad290d=yes
CC_OUTPUT_00792546_f2776b26=yes
CC_OUTPUT_00792546_b2657cc3=yes
CC_OUTPUT_00792546_380987f7=yes
CC_OUTPUT_00792546_160933ec=yes
CC_OUTPUT_00792546_fb62803b=yes
_OBJC_CCVERSION_00792546=FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1) Target: x86_64-unknown-freebsd12.1 Thread model: posix InstalledDir: /usr/bin
_OBJC_ALTCCVERSION_00792546=none
ARCH=amd64
OPSYS=FreeBSD
_OSRELEASE=12.1-RELEASE-p2
OSREL=12.1
OSVERSION=1201000
PYTHONBASE=/usr/local
HAVE_COMPAT_IA32_KERN=YES
_SMP_CPUS=12
CONFIGURE_MAX_CMD_LEN=262144
HAVE_PORTS_ENV=1
#### Misc Poudriere ####
GID=0
UID=0
---End make.conf---

ranlib libgold.a
clang++ -W -Wall    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=dwp  -pthread -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -Wno-c++11-narrowing -isystem /usr/local/include   -fstack-protector-strong  -o dwp dwp.o libgold.a ../libiberty/libiberty.a  /usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib   -lz -L/usr/local/lib
clang++ -W -Wall    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=ld-new  -pthread -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -Wno-c++11-narrowing -isystem /usr/local/include   -fstack-protector-strong  -o ld-new main.o i386.o x86_64.o sparc.o powerpc.o arm.o arm-reloc-property.o tilegx.o mips.o aarch64.o aarch64-reloc-property.o s390.o libgold.a ../libiberty/libiberty.a  /usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib   -lz -L/usr/local/lib
clang++ -W -Wall    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=incremental-dump  -pthread -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -Wno-c++11-narrowing -isystem /usr/local/include  -pthread -fstack-protector-strong  -o incremental-dump incremental-dump.o i386.o x86_64.o sparc.o powerpc.o arm.o arm-reloc-property.o tilegx.o mips.o aarch64.o aarch64-reloc-property.o s390.o libgold.a ../libiberty/libiberty.a /usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib   -lz -L/usr/local/lib
gmake[5]: Leaving directory '/wrkdirs/usr/ports/devel/binutils/work-native/binutils-2.33.1/gold'
gmake[4]: Leaving directory '/wrkdirs/usr/ports/devel/binutils/work-native/binutils-2.33.1/gold'
gmake[3]: Leaving directory '/wrkdirs/usr/ports/devel/binutils/work-native/binutils-2.33.1/gold'
gmake[2]: Leaving directory '/wrkdirs/usr/ports/devel/binutils/work-native/binutils-2.33.1'
gmake[1]: *** [Makefile:851: all] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/devel/binutils/work-native/binutils-2.33.1'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/binutils
=>> Cleaning up wrkdir
===>  Cleaning for binutils-2.33.1_2,1
build of devel/binutils | binutils-2.33.1_2,1 ended at Sun Feb 16 20:30:23 CET 2020
build time: 00:00:49
!!! build failure encountered !!!
Comment 16 Dimitry Andric freebsd_committer 2020-02-16 21:46:21 UTC
(In reply to freebsd from comment #15)
No, your pastebin shows different errors:

ld: error: undefined symbol: powerpc_num_opcodes
>>> referenced by ppc-dis.c
>>>               ppc-dis.o:(disassemble_init_powerpc) in archive ../opcodes/.libs/libopcodes.a
 
ld: error: undefined symbol: powerpc_opcodes
>>> referenced by ppc-dis.c
>>>               ppc-dis.o:(disassemble_init_powerpc) in archive ../opcodes/.libs/libopcodes.a
 
ld: error: undefined symbol: prefix_num_opcodes
>>> referenced by ppc-dis.c
>>>               ppc-dis.o:(disassemble_init_powerpc) in archive ../opcodes/.libs/libopcodes.a

As this is about PowerPC specific parts of binutils, you should open another bug with a reproduction scenario.
Comment 17 freebsd 2020-02-16 21:53:42 UTC
Ah sorry, jumped the gun there, will do.
Comment 18 mrT 2020-07-07 01:21:18 UTC
The patch has been available since end of January.
So why is it not available in
https://svnweb.freebsd.org/ports/head/devel/binutils/?view=log

I also checked freshports.org and it is not there either.

I will try to make due with the batch from this bug report any way.
Comment 19 Martin Filla 2020-07-07 07:47:40 UTC
This version is fixed.
# $FreeBSD: head/devel/binutils/Makefile 529050 2020-03-24 16:36:25Z bapt $

PORTNAME=       binutils
PORTVERSION=    2.33.1
PORTEPOCH?=     1
PORTREVISION=   2

Thx M.
Comment 20 mrT 2020-07-08 05:18:50 UTC
(In reply to Martin Filla from comment #19)

That is the revision I was trying to build.

After getting your comment, I decided to try again:
svn co -r 529050 http://svn.freebsd.org/ports/head/devel/binutils
     A    binutils/Makefile
     A    binutils/distinfo
     A    binutils/files
     A    binutils/files/patch-bfd_elfnn-aarch64.c
     A    binutils/files/patch-bfd_elfnn-riscv.c
     A    binutils/files/patch-bfd_elfxx-sparc.c
     A    binutils/files/patch-gas-configure.tgt
     A    binutils/files/patch-include__safe-ctype.h
     A    binutils/files/patch-mips64.diff
     A    binutils/files/patch-s390x.diff
     A    binutils/pkg-descr
     A    binutils/pkg-plist
     A    binutils/pkg-plist-aarch64
     A    binutils/pkg-plist-aarch64-none-elf
     A    binutils/pkg-plist-amd64
     A    binutils/pkg-plist-arm-gnueabi
     A    binutils/pkg-plist-arm-none-eabi
     A    binutils/pkg-plist-avr
     A    binutils/pkg-plist-i386
     A    binutils/pkg-plist-mingw32
     A    binutils/pkg-plist-mips
     A    binutils/pkg-plist-mips64
     A    binutils/pkg-plist-powerpc
     A    binutils/pkg-plist-powerpc64
     A    binutils/pkg-plist-riscv32-unknown-elf
     A    binutils/pkg-plist-riscv64
     A    binutils/pkg-plist-riscv64-none-elf
     A    binutils/pkg-plist-s390x
     A    binutils/pkg-plist-sparc64
     Checked out revision 529050.

I don't see any 'libcft-failures.diff' patch file there.

I also tried
svn co  http://svn.freebsd.org/ports/head/devel/binutils
     A    binutils/Makefile
     A    binutils/distinfo
     A    binutils/files
     A    binutils/files/patch-bfd_elfnn-aarch64.c
     A    binutils/files/patch-bfd_elfnn-riscv.c
     A    binutils/files/patch-bfd_elfxx-sparc.c
     A    binutils/files/patch-gas-configure.tgt
     A    binutils/files/patch-include__safe-ctype.h
     A    binutils/files/patch-mips64.diff
     A    binutils/files/patch-s390x.diff
     A    binutils/pkg-descr
     A    binutils/pkg-plist
     A    binutils/pkg-plist-aarch64
     A    binutils/pkg-plist-aarch64-none-elf
     A    binutils/pkg-plist-amd64
     A    binutils/pkg-plist-arm-gnueabi
     A    binutils/pkg-plist-arm-none-eabi
     A    binutils/pkg-plist-avr
     A    binutils/pkg-plist-i386
     A    binutils/pkg-plist-mingw32
     A    binutils/pkg-plist-mips
     A    binutils/pkg-plist-mips64
     A    binutils/pkg-plist-powerpc
     A    binutils/pkg-plist-powerpc64
     A    binutils/pkg-plist-riscv32-unknown-elf
     A    binutils/pkg-plist-riscv64
     A    binutils/pkg-plist-riscv64-none-elf
     A    binutils/pkg-plist-s390x
     A    binutils/pkg-plist-sparc64
     Checked out revision 541461.

Still no sign of 'libcft-failures.diff' patch file there.

I also tried:
https://github.com/freebsd/freebsd-ports/tree/master/devel/binutils

and again no sign of 'libcft-failures.diff' patch file there.


I tried searching all the files (including '.svn' directory) and didn't find anything suggesting the patch or 'swap' or related keywords.
This fails to build with the same link errors as in this bug report.
And the source files mentioned in 'libcft-failures.diff' patch file
are not patched.
What I used to build is:
  DEBUG_FLAGS="-g -O0 -gdwarf-4"; make -dxA WITH_DEBUG=1 MAKE_JOBS_NUMBER=1 DEBUG_MK_SCRIPTS=1
and searching the resulting log I did not find any mention of
'libcft-failures.diff' patch file and no attempt to patch source files
such as elfcpp/elfcpp_swap.h
        libctf/swap.h

I noticed that 'libcft-failures.diff' patch file contained a command line
    +diff -x .git -x autom4te.cache -durN binutils.orig/libctf/swap.h binutils/libctf/swap.h
Could it be that the '.git' repository has the devel/binutils with the
patch integrated but for some reason has not propagated to
http://svn.freebsd.org/ports/head/devel/binutils ?

I managed to apply the 'libcft-failures.diff' patch (to revision 529050)  that was posted as part of this bug report and it build without error.

I wish to report that this bug report is not fixed if 'fixed' means that the normal ways of obtaining ports would automatically have this patch applied than I fail to see how that could happen using the ports repositories mentioned above.

By the way, I discovered that (unlike most of my other ports searches)
    https://www.freebsd.org/ports/index.html
fails to show 'devel/binutils'
by specifying: search on: binutils  [package name]

but can show it by: search on ^binutils [package name]
and by: https://svnweb.freebsd.org/ports/head/devel/binutils/?view=log
and by: svn co -r 529050 http://svn.freebsd.org/ports/head/devel/binutils
and by: svn co  http://svn.freebsd.org/ports/head/devel/binutils
and by: https://github.com/freebsd/freebsd-ports/tree/master/devel/binutils
Comment 21 cryx-freebsd 2020-11-04 12:46:36 UTC
This affects me too when building binutils for gcc8 in poudriere.
Comment 22 Dimitry Andric freebsd_committer 2020-11-04 14:25:14 UTC
Accidentally filled in the wrong PR number in my commit:

A commit references this bug:

Author: dim
Date: Wed Nov  4 14:21:44 UTC 2020
New revision: 554081
URL: https://svnweb.freebsd.org/changeset/ports/554081

Log:
  devel/binutils: Apply upstream patch to fix "undefined symbol:
  bswap_identity_64" and similar errors, when building devel/binutils in
  certain environments.

  This has been sitting in a bug for almost a year now without any action,
  which is why I am committing it now.

  MFH:		2020Q4
  PR:		250783

Changes:
  head/devel/binutils/Makefile
  head/devel/binutils/files/patch-libctf_swap.h
Comment 23 commit-hook freebsd_committer 2020-11-05 16:19:45 UTC
A commit references this bug:

Author: dim
Date: Thu Nov  5 16:18:49 UTC 2020
New revision: 554138
URL: https://svnweb.freebsd.org/changeset/ports/554138

Log:
  MFH: r554081

  devel/binutils: Apply upstream patch to fix "undefined symbol:
  bswap_identity_64" and similar errors, when building devel/binutils in
  certain environments.

  This has been sitting in a bug for almost a year now without any action,
  which is why I am committing it now.

  Approved by:	ports-secteam (fluffy)
  PR:		242053

Changes:
_U  branches/2020Q4/
  branches/2020Q4/devel/binutils/Makefile
  branches/2020Q4/devel/binutils/files/patch-libctf_swap.h