Opened 2 years ago

Last modified 2 years ago

#64200 assigned defect

par2 @0.8.1+universal: Undefined symbols for architecture i386: ___atomic_compare_exchange ___atomic_load

Reported by: RobK88 Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: lion Cc:
Port: par2

Description

I am unable to upgrade the par2 port on Lion. The port fails at the build stage.

I also tried using clang-9.0 as the compiler without success. I will attach main.log.

port outdated
The following installed ports are outdated:
par2                           0.4_4 < 0.8.1_0 

grinch$ sudo port clean par2
--->  Cleaning par2

Grinchs-Mac-Pro:~ grinch$ sudo port -v upgrade par2
--->  Computing dependencies for par2.
--->  Fetching distfiles for par2
--->  Verifying checksums for par2
--->  Checksumming par2cmdline-0.8.1.tar.gz
--->  Extracting par2
--->  Extracting par2cmdline-0.8.1.tar.gz
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work" && /usr/bin/gzip -dc '/opt/local/var/macports/distfiles/par2/par2cmdline-0.8.1.tar.gz' | /usr/bin/gnutar --no-same-owner -xf - 
--->  Configuring par2
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work/par2cmdline-0.8.1" && ./configure --prefix=/opt/local --disable-dependency-tracking --mandir=/opt/local/share/man 
checking build system type... x86_64-apple-darwin11.4.2
checking host system type... x86_64-apple-darwin11.4.2
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /opt/local/bin/gmkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether /opt/local/bin/clang++-mp-9.0 accepts -g... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of /opt/local/bin/clang++-mp-9.0... none
checking for ranlib... ranlib
checking for gcc... /opt/local/bin/clang-mp-9.0
checking whether we are using the GNU C compiler... yes
checking whether /opt/local/bin/clang-mp-9.0 accepts -g... yes
checking for /opt/local/bin/clang-mp-9.0 option to accept ISO C89... none needed
checking whether /opt/local/bin/clang-mp-9.0 understands -c and -o together... yes
checking dependency style of /opt/local/bin/clang-mp-9.0... none
checking for ar... ar
checking the archiver (ar) interface... ar
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking how to run the C++ preprocessor... /opt/local/bin/clang++-mp-9.0 -E
checking for grep that handles long lines and -e... /opt/local/bin/ggrep
checking for egrep... /opt/local/bin/ggrep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... no
checking for _Bool... no
checking for ANSI C header files... (cached) yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking endian.h usability... no
checking endian.h presence... no
checking for endian.h... no
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for size_t... yes
checking whether byte ordering is bigendian... universal
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for _LARGEFILE_SOURCE value needed for large files... no
checking for /opt/local/bin/clang++-mp-9.0 option to support OpenMP... -fopenmp
checking for working memcmp... yes
checking for stricmp... no
checking for strcasecmp... yes
checking for strchr... yes
checking for memcpy... yes
checking for getopt... yes
checking for getopt_long... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating stamp-h
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
--->  Building par2
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work/par2cmdline-0.8.1" && /usr/bin/make -j4 -w all 
make: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work/par2cmdline-0.8.1'
/usr/bin/make  all-am
make[1]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work/par2cmdline-0.8.1'
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par2cmdline.o src/par2cmdline.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/commandline.o src/commandline.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/crc.o src/crc.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/creatorpacket.o src/creatorpacket.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/criticalpacket.o src/criticalpacket.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/datablock.o src/datablock.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/descriptionpacket.o src/descriptionpacket.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/diskfile.o src/diskfile.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/filechecksummer.o src/filechecksummer.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/galois.o src/galois.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/mainpacket.o src/mainpacket.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/md5.o src/md5.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par1fileformat.o src/par1fileformat.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par1repairer.o src/par1repairer.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par1repairersourcefile.o src/par1repairersourcefile.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par2creator.o src/par2creator.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par2creatorsourcefile.o src/par2creatorsourcefile.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par2fileformat.o src/par2fileformat.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par2repairer.o src/par2repairer.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/par2repairersourcefile.o src/par2repairersourcefile.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/recoverypacket.o src/recoverypacket.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/reedsolomon.o src/reedsolomon.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/verificationhashtable.o src/verificationhashtable.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/verificationpacket.o src/verificationpacket.cpp
/opt/local/bin/clang++-mp-9.0 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386 -c -o src/libpar2.o src/libpar2.cpp
rm -f libpar2.a
ar cru libpar2.a src/crc.o src/creatorpacket.o src/criticalpacket.o src/datablock.o src/descriptionpacket.o src/diskfile.o src/filechecksummer.o src/galois.o src/mainpacket.o src/md5.o src/par1fileformat.o src/par1repairer.o src/par1repairersourcefile.o src/par2creator.o src/par2creatorsourcefile.o src/par2fileformat.o src/par2repairer.o src/par2repairersourcefile.o src/recoverypacket.o src/reedsolomon.o src/verificationhashtable.o src/verificationpacket.o src/libpar2.o 
ranlib libpar2.a
ranlib: for architecture: x86_64 file: libpar2.a(galois.o) has no symbols
ranlib: for architecture: i386 file: libpar2.a(galois.o) has no symbols
/opt/local/bin/clang++-mp-9.0 -Wall -std=c++11 -fopenmp -pipe -Os -stdlib=libc++ -arch x86_64 -arch i386  -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -arch i386 -o par2 src/par2cmdline.o src/commandline.o libpar2.a 
Undefined symbols for architecture i386:
  "___atomic_compare_exchange", referenced from:
      _.omp_outlined..22 in libpar2.a(par2creator.o)
      Par2Repairer::ScanDataFile(DiskFile*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Par2RepairerSourceFile*&, MatchType&, MD5Hash&, MD5Hash&, unsigned int&) in libpar2.a(par2repairer.o)
      _.omp_outlined..97 in libpar2.a(par2repairer.o)
      Par2CreatorSourceFile::Open(NoiseLevel, std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, unsigned long long, unsigned long long&) in libpar2.a(par2creatorsourcefile.o)
  "___atomic_load", referenced from:
      _.omp_outlined..22 in libpar2.a(par2creator.o)
      Par2Repairer::ScanDataFile(DiskFile*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Par2RepairerSourceFile*&, MatchType&, MD5Hash&, MD5Hash&, unsigned int&) in libpar2.a(par2repairer.o)
      _.omp_outlined..97 in libpar2.a(par2repairer.o)
      Par2CreatorSourceFile::Open(NoiseLevel, std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, unsigned long long, unsigned long long&) in libpar2.a(par2creatorsourcefile.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [par2] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work/par2cmdline-0.8.1'
make: *** [all] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work/par2cmdline-0.8.1'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/work/par2cmdline-0.8.1" && /usr/bin/make -j4 -w all 
Exit code: 2
Error: Failed to build par2: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_par2/par2/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.     

Attachments (2)

main.log (21.2 KB) - added by RobK88 2 years ago.
main.log
main.2.log (99.2 KB) - added by RobK88 2 years ago.
main.log after trying the port with PortGroup muniversal 1.0 added.

Download all attachments as: .zip

Change History (11)

Changed 2 years ago by RobK88

Attachment: main.log added

main.log

comment:1 Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Summary: Unable to Upgrade par2par2 @0.8.1+universal: Undefined symbols for architecture i386: ___atomic_compare_exchange ___atomic_load

I assume you only see this problem with the +universal variant, since we show successful builds on the buildbot without the +universal variant.

comment:2 Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: julian@… removed
Owner: set to julian@…
Status: newassigned

You can try adding the line PortGroup muniversal 1.0 to the top of the portfile (after the PortSystem 1.0 line) to see if that fixes it.

comment:3 Changed 2 years ago by RobK88

Yes, I did not realize that I installed the previous version of par2 with the +universal variant.

After I added the PortGroup muniversal 1.0 to the top of the portfile (after the PortSystem 1.0 line), the port compiled just fine. But the new binary does not appear to be universal.

What does the PortGroup muniversal 1.0 do?

bash-3.2$ par2 --version
par2cmdline version 0.8.1

bash-3.2$ port installed par2
The following ports are currently installed:
  par2 @0.4_4+universal
  par2 @0.8.1_0 (active)

comment:4 Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: julian@… deleted

The muniversal portgroup performs multiple separate builds and lipo's the results together (if you select the +universal variant, which you don't appear to have done, so we don't know whether adding the muniversal portgroup fixed the problem).

Without the muniversal portgroup, MacPorts tries to do a single build that is for all architectures. Some ports build better with one method or the other.

comment:5 Changed 2 years ago by RobK88

Thanks for the explanation. I can see why you suggested that I give the muniversal 1.0 PortGroup a try.

Even with PortGroup muniversal 1.0 added to the par2 portfile, I am still unable to make the +universal build of par2. I see a pause when building. As you said, it sure looks like the par2 portfile with PortGroup muniversal 1.0 added, is trying to perform multiple builds. In this case, it looks like it is trying to perform at least two separate builds (one for x86_64 and another for i386?) but fails during the second build. I will attach main.log with the hope it may provide some additional insight.

So adding PortGroup muniversal 1.0 did NOT fix the problem. But it was definitely worth a try.

bash-3.2$ sudo port clean par2
--->  Cleaning par2
bash-3.2$ sudo port install par2 +universal
--->  Computing dependencies for par2
--->  Fetching distfiles for par2
--->  Verifying checksums for par2
--->  Extracting par2
--->  Configuring par2
--->  Building par2                                      
Error: Failed to build par2: command execution failed    
Error: See /opt/local/var/macports/logs/_Users_grinch_Macports_ports_archivers_par2/par2/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port par2 failed
bash-3.2$
Last edited 2 years ago by RobK88 (previous) (diff)

Changed 2 years ago by RobK88

Attachment: main.2.log added

main.log after trying the port with PortGroup muniversal 1.0 added.

comment:6 Changed 2 years ago by kencu (Ken)

This issue here is that clang-7+ (or maybe it was clang-6+) turned off the atomic support they had in compiler_rt, in favour of the x86_64 processor intrinsic functions. So all the atomics for i386 broke. There is a ticket here on trac about it somewhere.

I was in the process of adding them back on, and did on clang-7.0:

<https://github.com/macports/macports-ports/commit/c53a09036eb6c71a52055965b4d300441f22da5a#diff-9578d6c0e98781980e844e9e074581a3ab685b18058fae9f1877b25d9a35d945>

but didn't get to clang-9.0 before my enthusiasm for this kind of project waned.

<https://github.com/macports/macports-ports/blob/master/lang/llvm-9.0/Portfile>

Short story:

build with clang-5.0 (has it on), or clang-7.0 (fixed as above), or fix clang-9.0 like I did for clang-7.0 and build with clang-9.0.

Sure, they should all be done.

Last edited 2 years ago by kencu (Ken) (previous) (diff)

comment:7 Changed 2 years ago by kencu (Ken)

There is a backstory here. The compiler_rt atomics were apparently a rather gross hack that never had a chance of actually working right, as the code was statically linked into each binary and nobody knew what anybody else was doing with that memory. This kind of thing has to be apparently administered by a shared library that all executables use (makes sense). So it was turned off for a reason.

gcc does it right -- it ships a libatomic.dylib that you can / have to link in (manually on darwin, but that's another story), but that works properly.

You could also add a dep for libgcc and link in that libatomic.dylib, but at this point in time, just turning on the (apparently officially not-really-perfect-but-does-at-least-link-the-binary) compiler_rt versions would be considered "good enough" for the issues at hand.

comment:8 Changed 2 years ago by RobK88

Thanks Ken. I will try building par2 +universal using clang 7.0.

FYI -- there is an open ticket on the missing atomic builtins in clang-7.0 and greater for i386. It looks like Ken fixed Clang-7.0 leaving the newer clangs still missing the atomic builtins. See #58712

Last edited 2 years ago by RobK88 (previous) (diff)

comment:9 Changed 2 years ago by RobK88

I can confirm that par2 +universal builds just fine using clang-7.0 on Lion:

bash-3.2$ port installed par2
The following ports are currently installed:
  par2 @0.4_4+universal
  par2 @0.8.1_0+universal (active)
bash-3.2$
bash-3.2$ lipo -info `which par2`
Architectures in the fat file: /opt/local/bin/par2 are: i386 x86_64 
bash-3.2$
Last edited 2 years ago by RobK88 (previous) (diff)
Note: See TracTickets for help on using tickets.