Skip to content

Enable free-threaded builds of Python 3.14 on musl #571

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

Merged
merged 4 commits into from
Mar 20, 2025
Merged

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Mar 20, 2025

Extends #568

@zanieb
Copy link
Member Author

zanieb commented Mar 20, 2025

cpython-3.14> checking for --with-mimalloc...
cpython-3.14> configure: error: mimalloc requires stdatomic.h, use --without-mimalloc to disable mimalloc.

It's not clear why this fails yet. I presumed this was a problem with Clang 14, but this should be available there. We should reproduce and look at a config.log.

I was kindly linked to https://gist.github.com/corona10/09459355b64d395aba14eba5be6f6f63 which showed a compiler-rt issue as the culprit (not using our clang version or build system!):

configure:18535: checking for stdatomic.h
configure:18558: clang-19 -o conftest   -fsanitize=thread  conftest.c  >&5
/usr/bin/ld: cannot find /usr/local/lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.tsan.a: No such file or directory
clang-19: error: linker command failed with exit code 1 (use -v to see invocation)

I'll setup a local build so I can see if the same thing is happening to us.

cc @indygreg in case there's something obvious here?

resolved in 5786594

@indygreg
Copy link
Collaborator

Why is thread sanitizer not working a fatal configure error? That seems like the underlying issue here.

@zanieb
Copy link
Member Author

zanieb commented Mar 20, 2025

I'm not sure. It might not be relevant — that build includes --with-thread-sanitizer and ours does not. I'll get logs for our setup.

@zanieb
Copy link
Member Author

zanieb commented Mar 20, 2025

Yeah that looks irrelevant

configure:18506: checking for stdatomic.h
configure:18529: musl-clang -o conftest  -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw  -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw  -L/tools/deps/lib -Wl,--exclude-libs,ALL -LModules/_hacl conf
test.c -ldl  -lpthread >&5
conftest.c:158:14: fatal error: 'stdatomic.h' file not found
    #include <stdatomic.h>
             ^~~~~~~~~~~~~
1 error generated.
configure:18529: $? = 1
configure: failed program was:

...

| 
| 
|     #include <stdatomic.h>
|     atomic_int int_var;
|     atomic_uintptr_t uintptr_var;
|     int main() {
|       atomic_store_explicit(&int_var, 5, memory_order_relaxed);
|       atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed);
|       int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst);
|       return 0;
|     }
| 
| 
configure:18541: result: no

@zanieb
Copy link
Member Author

zanieb commented Mar 20, 2025

This file is present in Clang 14 (as expected)

root@5e42d8cf2e23:~/Python-3.14.0a6# find $(musl-clang -print-file-name=include) -name stdatomic.h
/tools/llvm/lib/clang/14.0.3/include/stdatomic.h

@zanieb
Copy link
Member Author

zanieb commented Mar 20, 2025

Trying d335fbf as we do for the intrinsic headers for blake2 (edit: this worked)

@indygreg
Copy link
Collaborator

It's possible musl-clang's implicit compiler options are not using clang's normal includes search paths. That musl-clang wrapper does weird things.

There's an arg to tell clang to dump all its arguments upon invocation. Can't recall offhand. Add that to see what's actually going on.

@zanieb zanieb marked this pull request as ready for review March 20, 2025 15:23
@zanieb zanieb requested a review from geofft March 20, 2025 15:29
Comment on lines +416 to +414
filename=$(basename "$h")
if [ -e "/tools/host/include/${filename}" ]; then
echo "${filename} already exists; don't need to copy!"
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this my bash scripting knowledge failing me or are you bailing on the entire build here if the include file exists?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhh I guess so, I copied this from above though. It seems fine to bail because it's a wrong assumption in the build script.

Base automatically changed from zb/musl-314 to main March 20, 2025 22:09
@zanieb zanieb merged commit f0abfc9 into main Mar 20, 2025
40 checks passed
@zanieb zanieb deleted the zb/musl-314-ft branch March 20, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants