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 on RISC-V: undefined reference to `__atomic_exchange_1' #112779

Closed
furkanonder opened this issue Dec 5, 2023 · 5 comments
Closed
Labels
build The build process and cross-build type-bug An unexpected behavior, bug, or error

Comments

@furkanonder
Copy link
Contributor

furkanonder commented Dec 5, 2023

Bug report

Bug description:

Configuration:

./configure

Build Output (full-build-output.txt):

user@starfive:~/cpython$ make  
gcc -c -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I./Include/internal/mimalloc  -I. -I./Include    -DPy_BUILD_CORE -o Programs/_freeze_module.o Programs/_freeze_module.c
gcc -c -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I./Include/internal/mimalloc  -I. -I./Include    -DPy_BUILD_CORE -o Modules/getpath_noop.o Modules/getpath_noop.c
gcc     -o Programs/_freeze_module Programs/_freeze_module.o Modules/getpath_noop.o Modules/getbuildinfo.o Parser/token.o  Parser/pegen.o Parser/pegen_errors.o Parser/action_helpers.o Parser/parser.o Parser/string_parser.o Parser/peg_api.o Parser/lexer/buffer.o Parser/lexer/lexer.o Parser/lexer/state.o Parser/tokenizer/file_tokenizer.o Parser/tokenizer/readline_tokenizer.o Parser/tokenizer/string_tokenizer.o Parser/tokenizer/utf8_tokenizer.o Parser/tokenizer/helpers.o Parser/myreadline.o Objects/abstract.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/call.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genericaliasobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/interpreteridobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/picklebufobject.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/typevarobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/unionobject.o Objects/weakrefobject.o  Python/_warnings.o Python/Python-ast.o Python/Python-tokenize.o Python/asdl.o Python/assemble.o Python/ast.o Python/ast_opt.o Python/ast_unparse.o Python/bltinmodule.o Python/ceval.o Python/codecs.o Python/compile.o Python/context.o Python/critical_section.o Python/crossinterp.o Python/dynamic_annotations.o Python/errors.o Python/flowgraph.o Python/frame.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/ceval_gil.o Python/hamt.o Python/hashtable.o Python/import.o Python/importdl.o Python/initconfig.o Python/instrumentation.o Python/intrinsics.o Python/legacy_tracing.o Python/lock.o Python/marshal.o Python/modsupport.o Python/mysnprintf.o Python/mystrtoul.o Python/optimizer.o Python/optimizer_analysis.o Python/parking_lot.o Python/pathconfig.o Python/preconfig.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/bootstrap_hash.o Python/specialize.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/thread.o Python/traceback.o Python/tracemalloc.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/suggestions.o Python/perf_trampoline.o Python/dynload_shlib.o     Modules/config.o Modules/main.o Modules/gcmodule.o Modules/atexitmodule.o  Modules/faulthandler.o  Modules/posixmodule.o  Modules/signalmodule.o  Modules/_tracemalloc.o  Modules/_codecsmodule.o  Modules/_collectionsmodule.o  Modules/errnomodule.o  Modules/_io/_iomodule.o Modules/_io/iobase.o Modules/_io/fileio.o Modules/_io/bytesio.o Modules/_io/bufferedio.o Modules/_io/textio.o Modules/_io/stringio.o  Modules/itertoolsmodule.o  Modules/_sre/sre.o  Modules/_sysconfig.o  Modules/_threadmodule.o  Modules/timemodule.o  Modules/_typingmodule.o  Modules/_weakref.o  Modules/_abc.o  Modules/_functoolsmodule.o  Modules/_localemodule.o  Modules/_operator.o  Modules/_stat.o  Modules/symtablemodule.o  Modules/pwdmodule.o -ldl                          -lm 
/usr/bin/ld: Python/critical_section.o: in function `PyMutex_Lock':
/home/user/cpython/./Include/internal/pycore_lock.h:72: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: /home/user/cpython/./Include/internal/pycore_lock.h:72: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: Python/critical_section.o: in function `_Py_atomic_compare_exchange_uint8':
/home/user/cpython/./Include/cpython/pyatomic_gcc.h:105: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: /home/user/cpython/./Include/cpython/pyatomic_gcc.h:105: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: Python/critical_section.o: in function `_PyCriticalSection_Resume':
/home/user/cpython/Python/critical_section.c:80: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: Python/critical_section.o:/home/user/cpython/Python/critical_section.c:90: more undefined references to `__atomic_compare_exchange_1' follow
/usr/bin/ld: Python/lock.o: in function `_Py_atomic_compare_exchange_uintptr':
/home/user/cpython/./Include/cpython/pyatomic_gcc.h:125: undefined reference to `__atomic_exchange_1'
/usr/bin/ld: Python/lock.o: in function `_PyEvent_Notify':
/home/user/cpython/Python/lock.c:267: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: Python/lock.o: in function `PyEvent_Wait':
/home/user/cpython/Python/lock.c:272: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: Python/lock.o: in function `_PyOnceFlag_CallOnceSlow':
/home/user/cpython/Python/lock.c:325: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: Python/lock.o: in function `_Py_atomic_compare_exchange_uint8':
/home/user/cpython/./Include/cpython/pyatomic_gcc.h:105: undefined reference to `__atomic_compare_exchange_1'
/usr/bin/ld: Python/lock.o: in function `_PyOnceFlag_CallOnceSlow':
/home/user/cpython/Python/lock.c:352: undefined reference to `__atomic_exchange_1'
collect2: error: ld returned 1 exit status
make: *** [Makefile:1342: Programs/_freeze_module] Error 1

Enviroment:

user@starfive:~/cpython$  ld -v
GNU ld (GNU Binutils for Debian) 2.39.50.20221224
user@starfive:~/cpython$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-linux-gnu/12/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 12.2.0-10' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Debian 12.2.0-10) 
user@starfive:~/cpython$ make -v
GNU Make 4.3
Built for riscv64-unknown-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
user@starfive:~/cpython$ uname -a
Linux starfive 5.15.0-starfive #1 SMP Fri Nov 24 07:22:28 UTC 2023 riscv64 GNU/Linux
user@starfive:~/cpython$ 

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

@furkanonder furkanonder added type-bug An unexpected behavior, bug, or error build The build process and cross-build labels Dec 5, 2023
@colesbury
Copy link
Contributor

This looks like #110828 and #109054. Can you share the configure output?

@furkanonder furkanonder changed the title Build Error on Riscv64[Waveshare VisionFive2] undefined reference to `__atomic_exchange_1' Build Error on RISC-V[Waveshare VisionFive2] undefined reference to `__atomic_exchange_1' Dec 6, 2023
@furkanonder furkanonder changed the title Build Error on RISC-V[Waveshare VisionFive2] undefined reference to `__atomic_exchange_1' Build Error on RISC-V undefined reference to `__atomic_exchange_1' Dec 6, 2023
@furkanonder
Copy link
Contributor Author

This looks like #110828 and #109054. Can you share the configure output?

configure-output.txt

@furkanonder furkanonder changed the title Build Error on RISC-V undefined reference to `__atomic_exchange_1' Build Error on RISC-V: undefined reference to `__atomic_exchange_1' Dec 6, 2023
@colesbury
Copy link
Contributor

checking whether libatomic is needed by <pyatomic.h>... no

It looks like the configure check doesn't think libatomic is needed even though it actually is. Maybe GCC needs library support for 1-byte atomics on RISC-V, but not the 8-byte atomic operations used in the configure check.

@colesbury
Copy link
Contributor

@furkanonder - can you try out #112819?

@furkanonder
Copy link
Contributor Author

@furkanonder - can you try out #112819?

@colesbury I have compiled it successfully.

user@starfive:~/colesbury/cpython$ ./python
Python 3.13.0a2+ (heads/riscv-atomics:1807f54866, Dec  7 2023, 20:03:32) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants