build error on OS X 10.7: Cannot implement AO_compare_and_swap_full on this architecture
mojca opened this issue · 22 comments
When building the version from master on OS X 10.7, it fails with
libtool: compile: /usr/bin/clang -DHAVE_CONFIG_H -I../src -I../src -I/opt/local/include -fPIC -Wall -Wextra -Wpedantic -Wno-long-long -pipe -Os -arch x86_64 -MT atomic_ops.lo -MD -MP -MF .deps/atomic_ops.Tpo -c atomic_ops.c -o atomic_ops.o
In file included from atomic_ops_stack.c:23:
In file included from ../src/atomic_ops_stack.h:32:
../src/atomic_ops.h:383:5: error: Cannot implement AO_compare_and_swap_full on this architecture.
# error Cannot implement AO_compare_and_swap_full on this architecture.
^
1 error generated.
Version 7.4.4 works fine.
Output from configure
:
checking build system type... x86_64-apple-darwin11.4.2
checking host system type... x86_64-apple-darwin11.4.2
checking target 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 to enable maintainer-specific portions of Makefiles... no
checking for style of include used by make... GNU
checking for gcc... /usr/bin/clang
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 /usr/bin/clang accepts -g... yes
checking for /usr/bin/clang option to accept ISO C89... none needed
checking whether /usr/bin/clang understands -c and -o together... yes
checking dependency style of /usr/bin/clang... gcc3
checking dependency style of /usr/bin/clang... gcc3
checking how to print strings... printf
checking for a sed that does not truncate output... /opt/local/bin/gsed
checking for grep that handles long lines and -e... /opt/local/bin/grep
checking for egrep... /opt/local/bin/grep -E
checking for fgrep... /opt/local/bin/grep -F
checking for ld used by /usr/bin/clang... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /opt/local/bin/nm
checking the name lister (/opt/local/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking how to convert x86_64-apple-darwin11.4.2 file names to x86_64-apple-darwin11.4.2 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin11.4.2 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /opt/local/bin/nm output from /usr/bin/clang object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking how to run the C preprocessor... /usr/bin/clang -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 dlfcn.h... yes
checking for objdir... .libs
checking if /usr/bin/clang supports -fno-rtti -fno-exceptions... yes
checking for /usr/bin/clang option to produce PIC... -fno-common -DPIC
checking if /usr/bin/clang PIC flag -fno-common -DPIC works... yes
checking if /usr/bin/clang static flag -static works... no
checking if /usr/bin/clang supports -c -o file.o... yes
checking if /usr/bin/clang supports -c -o file.o... (cached) yes
checking whether the /usr/bin/clang linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin11.4.2 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking for PIC compiler flag... -fPIC
checking whether gcc -fPIC causes __PIC__ definition... yes
checking for gcc -Wextra... yes
checking for gcc -Wpedantic... yes
checking for pthread_self in -lpthread... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating pkgconfig/atomic_ops.pc
config.status: creating pkgconfig/atomic_ops-uninstalled.pc
config.status: creating src/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default commands
Using a newer compiler like clang-3.4 helps though.
- Which clang version does iOS X 10.7 have?
- Does CFLAGS=-DAO_GCC_FORCE_HAVE_CAS (passed to make) help?
- Which clang version does iOS X 10.7 have?
> clang --version
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
(Not iOS.)
- Does CFLAGS=-DAO_GCC_FORCE_HAVE_CAS (passed to make) help?
Will test and let you know.
Please also provide output of:
clang -dM -E src/atomic_ops.c | grep __GNUC
And of:
clang -dM -E src/atomic_ops.c | grep __clang_m
Also please do the same (clang-3.4 --version, clang-3.4 -dM ...) for clang-3.4
Oh, this is semi-useless, sorry.
Please note that the values provided by the compiler shipped by Apple are different from the values when compiling the compiler yourself. I can try to dig out the code that does this differentiation and it's a bit of a horror.
> clang -dM -E src/atomic_ops.c | grep __GNUC
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __GNUC_STDC_INLINE__ 1
#define __GNUC__ 4
> clang -dM -E src/atomic_ops.c | grep __clang_m
#define __clang_major__ 4
#define __clang_minor__ 2
> clang-mp-3.4 -dM -E src/atomic_ops.c | grep __GNUC
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __GNUC_STDC_INLINE__ 1
#define __GNUC__ 4
> clang-mp-3.4 -dM -E src/atomic_ops.c | grep __clang_m
#define __clang_major__ 3
#define __clang_minor__ 4
- Does CFLAGS=-DAO_GCC_FORCE_HAVE_CAS (passed to make) help?
Yes, that seems to work. The compilation is successful if I do
export CFLAGS=-DAO_GCC_FORCE_HAVE_CAS
before running configure
.
Oh, this is semi-useless, sorry.
Luckily this is not need to fix the issue because we know that x64 has CAS.
I will submit a patch within a day.
Fixed.
Thank you, that solves the problem on 10.7.
For x86_64, that is.
Building for i386 is still broken:
libtool: compile: /usr/bin/clang -DHAVE_CONFIG_H -I../src -I../src -I/opt/local/include -fPIC -Wall -Wextra -Wpedantic -Wno-long-long -pipe -Os -arch i386 -c atomic_ops_stack.c -o atomic_ops_stack.o
In file included from atomic_ops_stack.c:23:
In file included from ../src/atomic_ops_stack.h:32:
../src/atomic_ops.h:383:5: error: Cannot implement AO_compare_and_swap_full on this architecture.
# error Cannot implement AO_compare_and_swap_full on this architecture.
^
1 error generated.
Thank you. The build is fixed now. The tests (still?) fail (when building on x86_64 for i386), but I guess they also failed earlier, at least according to some comments.
libtool: link: /usr/bin/clang -Wall -Wextra -Wpedantic -Wno-long-long -pipe -Os -arch i386 -Wl,-headerpad_max_install_names -arch i386 -o test_atomic test_atomic.o -L/opt/local/lib ../src/.libs/libatomic_ops.a
Undefined symbols for architecture i386:
"___atomic_load", referenced from:
_test_atomic in test_atomic.o
_test_atomic_acquire in test_atomic.o
_test_atomic_read in test_atomic.o
_test_atomic_full in test_atomic.o
_test_atomic_acquire_read in test_atomic.o
_test_atomic_dd_acquire_read in test_atomic.o
"___atomic_store", referenced from:
_test_atomic in test_atomic.o
_test_atomic_release in test_atomic.o
_test_atomic_write in test_atomic.o
_test_atomic_full in test_atomic.o
_test_atomic_release_write in test_atomic.o
ld: symbol(s) not found for architecture i386
It is unclear which exactly __atomic_load/store are missing.
Please try a build with: CFLAGS="-DAO_SKIPATOMIC_double_load -DAO_SKIPATOMIC_double_load_acquire -DAO_SKIPATOMIC_double_store -DAO_SKIPATOMIC_double_store_release"
The tests succeed if I add those flags.
Good, so it is clear how to fix it but we should distinguish between clang/OS versions somehow. E.g. clang-703 in OS X 10.11 does not need this workaround. I think we could rely on checking value of
__apple_build_version__ predefined macro. What is the output of "clang -dM -E ,,, | grep __apple_build_version__" on your host?
I plan to prepare the fix on Jan 10.
#define __apple_build_version__ 4250028
See https://trac.macports.org/wiki/XcodeVersionInfo.
But I tried to compile with clang 3.8 and I get the same error during testing of i386 binaries (__apple_build_version__
is not defined there). I guess I should test whether this works without modifications on the latest macOS.
> I guess I should test whether this works without modifications on the latest macOS.
Yes, please test it, I have tested it only on x64.
I have tested it in 32-bit mode with clang-800 - it works:
make -j check CFLAGS_EXTRA=-m32
If think the proper way is to include AvailabilityMacros.h and define the above SKIP macros for i686 if MAC_OS_X_VERSION_MIN_REQUIRED < 101200 (or MAC_OS_X_VERSION_MIN_REQUIRED is undefined).
Would be good if you could test on OS X 10.11 and/or older one (whether they have the same issue as in OS X 10.7).
Thank you.