Description
OS : mac
command: buildozer -v android debug
buildozer.spec : p4a.branch = develop
Can someone point why is this ld error caused while building 'kiwisolver._cext' extension
[DEBUG]: /Users/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -target aarch64-linux-android24 -fomit-frame-pointer -march=armv8-a -fPIC -target aarch64-linux-android24 -fomit-frame-pointer -march=armv8-a -fPIC -I/Users/workspace/stocks/android/matplotlibapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_24/python3/Include -bundle -undefined dynamic_lookup -L/Users/workspace/stocks/android/matplotlibapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/libs_collections/matplotlibapp/arm64-v8a -L/Users/workspace/stocks/android/matplotlibapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_24/python3/android-build -lpython3.11 -target aarch64-linux-android24 -fomit-frame-pointer -march=armv8-a -fPIC -I/Users/workspace/stocks/android/matplotlibapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_24/python3/Include build/temp.macosx-15.3-arm64-cpython-311/py/src/constraint.o build/temp.macosx-15.3-arm64-cpython-311/py/src/expression.o build/temp.macosx-15.3-arm64-cpython-311/py/src/kiwisolver.o build/temp.macosx-15.3-arm64-cpython-311/py/src/solver.o build/temp.macosx-15.3-arm64-cpython-311/py/src/strength.o build/temp.macosx-15.3-arm64-cpython-311/py/src/term.o build/temp.macosx-15.3-arm64-cpython-311/py/src/variable.o -o build/lib.macosx-15.3-arm64-cpython-311/kiwisolver/_cext.cpython-311-darwin.so -stdlib=libc++
[DEBUG]: clang-14: warning: argument unused during compilation: '-bundle' [-Wunused-command-line-argument]
[DEBUG]: clang-14: warning: argument unused during compilation: '-undefined dynamic_lookup' [-Wunused-command-line-argument]
[DEBUG]: ld: error: undefined symbol: main
[DEBUG]: >>> referenced by crtbegin.c
Activity
AndreMiras commentedon Mar 7, 2025
Did you get this working in the past or is it the first time you're trying?
I'm asking because we made a recent kiwisolver recipe update.
You can verify if this is a regression from #3118 by pointing
p4a.commit
to the commit before the merge. Start from clean build.If it's a recent regression then the fix is simple.
T-Dynamos commentedon Mar 7, 2025
That's same error macos runner is having in github right now.
shivaraj-arch commentedon Mar 7, 2025
if
__init__.py
is replaced, old error resurfaces - Python.h not found.tried setting env flags but seems its not finding it. should we set them in another file?
RobertFlatt commentedon Mar 11, 2025
@T-Dynamos
I think the recipe should have
+=
not=
here:Because the log error is due to trying to create an executable, so some compiler flags are wrong. And other recipes use
+=
in this case.Update __init__.py
RobertFlatt commentedon Mar 12, 2025
I tried adding the above fix to a very loosely related PR #3124
It did not fix the issue.
RobertFlatt commentedon Mar 14, 2025
I note the following warnings
These two options tell Clang to link as a
.so
, Clang is not seeing them and we get an executable.These flags only occur in the link step.
The general form of the link on MacOS is (the
extra_include_file
is fromCPPFLAGS
, andCFLAGS
is not used) .Linux replaces
-bundle -undefined dynamic_lookup
(from the warnings above) with-shared
.It looks like MacOS is picky about argument order. I suggest this will not be specific to this recipe. And will occur when CPPFLAGS is set in a recipe.
The resolution is probably not to supply compile options to a link step. (And definitely not twice!).
As far as I can see
PyProjectRecipe
would have to make the distinction betweensetuptools
extra_compile_args
, andextra_link_args
. Its child MesonRecipe does make this distinction.For the case of args supplied from a recipe, I think these should/could not be specified from a .toml file, so this is a
PyProjectRecipe
use ofsetuptools
issue.@T-Dynamos
@AndreMiras
AndreMiras commentedon Mar 20, 2025
Thank you for your input @RobertFlatt , yes that sounds reasonable, that could be it.
This can probably be confirmed by updating the
kiwisolver
recipe and sanitizing the linker flags.I don't have access to macOS 13 or 14 to try sadly (I've tried playing with sickcodes/Docker-OSX, but no luck so far) and debugging using the CI only is a bit impractical.
Feel free to give it a try if you have a chance to. Ideally I wouldn't refactor the base recipe classes, but try to fix at
kiwisolver
level first to confirm it with a low regression riskRobertFlatt commentedon Mar 21, 2025
@AndreMiras
Testing my opinions written above sounds like a really good idea! I don't have Mac access either.
I did dig around in
recipy.py
, couldn't find anything lower level thanPyProjectRecipy
's call to setuptools. Which makes some sense. But I couldn't find the default usage of CPPFLAGS either , so I know that I don't know how those pieces fit together. I'd be a fool to try to mess with that. ButPyProjectRecipy
looks like the place that configures setuptools build.Don't really need a Mac initially, it is sufficient to look at the compile argument order on an Android build (assuming the reasoning in the previous post). The Android Clang, of course does not complain.
Since
PyProjectRecipe
is new and only in the p4a develop version (and undocumented), I suggest the developer owns this one.AndreMiras commentedon Mar 22, 2025
So I got a macOS 13 (Ventura) setup working using dockur/macos to try to reproduce, but I can successfully build kiwisolver with it 🤷♂
Steps to reproduce:
It's weird that I'm trying to run it just like in the CI and it works for me 🤯
I'll keep investigating when I get a chance.
Truncated log end for reference:
🐛 Fix the kiwisolver build on macOS, fixes #3122
🐛 Fix the kiwisolver build on macOS, fixes #3122
AndreMiras commentedon Mar 22, 2025
Fixed via #3128, I'll let the PR open until tomorrow and merge it if we don't get blocking comments.
I kept it isolated instead of touching
PyProjectRecipe
to limit potential regressions.If we can confirm the same bug on macOS for another
PyProjectRecipe
then we can try to generalise itRobertFlatt commentedon Mar 22, 2025
The condition I think will be
PyProjectRecipe
containingCPPFLAGS
.Merge pull request #3128 from kivy/feature/fix_kiwisolver_macos
shivaraj-arch commentedon Mar 24, 2025
Thanks all for the fix.
env["LDFLAGS"] += " -shared"