Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error in ARM64 Mac system #353

Closed
sigmafelix opened this issue Nov 28, 2020 · 14 comments
Closed

Build error in ARM64 Mac system #353

sigmafelix opened this issue Nov 28, 2020 · 14 comments

Comments

@sigmafelix
Copy link

Hello,
I am trying to build geos in my ARM64 Mac system, but I am getting an error when the make process gets to make a dynamic library:

% sudo /usr/local/bin/cmake .
-- GEOS: Using default build type: Release
-- GEOS: Run-time output: /Users/isong/Downloads/geos/bin
-- GEOS: Archives output: /Users/isong/Downloads/geos/lib
-- GEOS: Version 3.9.0dev
-- GEOS: C API Version 1.14.0
-- GEOS: JTS port 1.16.0
-- GEOS: Require C++11
-- GEOS: Developer mode enabled
-- GEOS: Configured 'dist' target
-- GEOS: Configured 'distcheck' target
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/isong/Downloads/geos
isong@Insangs-MacBook-Pro geos % sudo /usr/local/bin/make . 
isong@Insangs-MacBook-Pro geos % sudo /usr/local/bin/make  
[  0%] Linking CXX shared library lib/libgeos.dylib
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    CMakeFiles/geos.dir/src/inlines.cpp.o
    CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    CMakeFiles/geos.dir/src/inlines.cpp.o
    CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    CMakeFiles/geos.dir/src/inlines.cpp.o
    CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/geos.dir/build.make:5383: lib/libgeos.3.9.0.dylib] Error 1
make[1]: *** [CMakeFiles/Makefile2:817: CMakeFiles/geos.dir/all] Error 2
make: *** [Makefile:182: all] Error 2

Does anyone have an idea for the error?
Thank you.

@pramsey
Copy link
Member

pramsey commented Nov 28, 2020

No, that's really a very nonsensical error... it's trying to link the library before it's built any of the object files? Or did you delete all the rest of the log? Anyways, it looks like the error you reported before? Duplicate symbols, probably (my guess) in the inline file? As before, I don't tend to blame the architecture, as I can build on AWS ARM.

@dbaston
Copy link
Member

dbaston commented Nov 28, 2020

Looks like the same error @robe2 gets on Windows when enabling inlining. It should build successfully with -DDISABLE_GEOS_INLINE, thought that's a bad workaround with big performance impacts. Would be nice to figure out the actual fix.

@tzakharko
Copy link
Contributor

Could it somehow be connected to #288? CMake is black magic to me unfortunately, but maybe it might give one of you more knowledgeable people an idea.

@pramsey
Copy link
Member

pramsey commented Dec 9, 2020

You might find that the current master works. It now builds/regresses on AWS ARM64 with all compilers.

@tzakharko
Copy link
Contributor

tzakharko commented Dec 9, 2020

@pramsey Unfortunately, I am still getting the same error. BasicSegmentString symbol somehow ends up in two different object files (inlines.cpp.o and BasicSegmentString.cpp.o) that are linked together, generating a linker error.

@dbaston
Copy link
Member

dbaston commented Dec 10, 2020

@tzakharko does the workaround I suggested fix it for you? Not suggesting that it's a solution, but if you can confirm the fix, it might help track down the actual solution.

@tzakharko
Copy link
Contributor

@dbaston Sorry for the lack of concrete feedback. Here is the full report:

  1. The default build crashes when linking the dynamic library (libgeos.3.9.0beta2.dylib) with the aforementioned error

  2. With -DDISABLE_GEOS_INLINE=ON the build is successful and passes all tests

  3. With -DBUILD_SHARED_LIBS=OFF (I thought I'll try it out since the linker could not build the dylib) I get a similar error, but this time linking everything else. Relevant part of the build log is attached. The interesting thing, it's always BasicSegmentString...

Build log for -DBUILD_SHARED_LIBS=OFF
[ 62%] Linking CXX executable ../../bin/perf_unaryunion_segments
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[ 62%] Built target perf_class_sizes
make[2]: *** [bin/perf_interiorpoint_area] Error 1
make[1]: *** [benchmarks/algorithm/CMakeFiles/perf_interiorpoint_area.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 62%] Linking CXX executable ../../bin/test_simplewkttester
Scanning dependencies of target perf_iterated_buffer
[ 62%] Building CXX object tests/xmltester/CMakeFiles/test_xmltester.dir/BufferResultMatcher.cpp.o
[ 63%] Linking CXX executable ../../bin/perf_voronoi
[ 63%] Building CXX object benchmarks/operation/buffer/CMakeFiles/perf_iterated_buffer.dir/IteratedBufferStressTest.cpp.o
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
make[2]: *** [bin/perf_unaryunion_segments] Error 1
ld: 3 duplicate symbols for architecture arm64
make[1]: *** [benchmarks/algorithm/CMakeFiles/perf_unaryunion_segments.dir/all] Error 2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/test_simplewkttester] Error 1
make[1]: *** [tests/xmltester/CMakeFiles/test_simplewkttester.dir/all] Error 2
[ 63%] Building CXX object tests/xmltester/CMakeFiles/test_xmltester.dir/tinyxml2/tinyxml2.cpp.o
[ 63%] Building CXX object tests/xmltester/CMakeFiles/test_xmltester.dir/SingleSidedBufferResultMatcher.cpp.o
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/perf_voronoi] Error 1
make[1]: *** [benchmarks/algorithm/CMakeFiles/perf_voronoi.dir/all] Error 2
[ 63%] Linking CXX executable ../../bin/test_big_sweep_line_speed
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/test_big_sweep_line_speed] Error 1
make[1]: *** [tests/bigtest/CMakeFiles/test_big_sweep_line_speed.dir/all] Error 2
[ 63%] Linking CXX executable ../../../bin/perf_iterated_buffer
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    ../../../lib/libgeos.a(inlines.cpp.o)
    ../../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    ../../../lib/libgeos.a(inlines.cpp.o)
    ../../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    ../../../lib/libgeos.a(inlines.cpp.o)
    ../../../lib/libgeos.a(BasicSegmentString.cpp.o)
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/perf_iterated_buffer] Error 1
make[1]: *** [benchmarks/operation/buffer/CMakeFiles/perf_iterated_buffer.dir/all] Error 2
[ 64%] Linking CXX executable ../../bin/test_xmltester
duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    ../../lib/libgeos.a(inlines.cpp.o)
    ../../lib/libgeos.a(BasicSegmentString.cpp.o)
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/test_xmltester] Error 1
make[1]: *** [tests/xmltester/CMakeFiles/test_xmltester.dir/all] Error 2
[ 64%] Linking CXX static library lib/libgeos_c.a
[ 64%] Built target geos_c
make: *** [all] Error 2

I couldn't find any other relevant build settings to play with. If you have any ideas, I will gladly be your guinea pig.

@dbaston
Copy link
Member

dbaston commented Dec 11, 2020

Thanks @tzakharko . This looks looks like the same problem that @robe2 has with the Windows build. I am inclined to suspect the ifdef in inlines.cpp: https://github.com/libgeos/geos/blob/master/src/inlines.cpp#L31 needs to be adjusted to effectively disable the file for your platform.

Another option is to remove the file for all platforms. It's not clear to me what problem it's solving. Looks like @strk added it in 2006; maybe he can elaborate? 984bc71

@pramsey
Copy link
Member

pramsey commented Dec 11, 2020

Yes, it seems odd to me that the inline functions aren't just in the appropriate headers with INLINE and a #define to switch that to inline as desired.

@tzakharko
Copy link
Contributor

Thanks @dbaston, this has been most helpful. Yes, the C++ ABI woes...

I have now submitted a simple "fix" as you have suggested. Seems to build fine on my Apple M1 laptop and passes all the tests. The tests also run 50% faster than on my 5.0ghz Intel machine, which is a nice bonus.

@tzakharko
Copy link
Contributor

@pramsey I have noticed that the ARM64 fix unfortunately didn't make the cut for the 3.9.0 release... I know it is a bit awkward to ask, but what are the chances of a short-term official version that would build on new Apple hardware? There is some popular open-source software that is currently being blocked on geos and Homebrew (an unofficial Mac package manager) maintainers don't feel too comfortable using a version from trunk...

@pramsey
Copy link
Member

pramsey commented Dec 20, 2020 via email

@pramsey
Copy link
Member

pramsey commented Dec 21, 2020

I have pulled that commit back into 3.8 and 3.9. Thanks!

@pramsey pramsey closed this as completed Dec 21, 2020
buildroot-auto-update pushed a commit to buildroot/buildroot that referenced this issue Jan 24, 2021
Disable inlining which raise build failures on arm.
It should be noted that inlining is already disabled by usptream on
arm64: libgeos/geos#353

Fixes:
 - http://autobuild.buildroot.org/results/52024b2ccc5d17612731809a5dabcc29a4a1170b

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
@hobu
Copy link
Member

hobu commented Jan 11, 2022

Reporting in that inlines with CMake appear to be working fine for me on osx-arm64

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants