-
Notifications
You must be signed in to change notification settings - Fork 1.5k
tools/ci/platforms/darwin.sh: Port NuttX CI Job to macOS-14 #14691
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
Conversation
also runs old CI Job macOS-13
|
Hi @lupyuen can you run a test on real macOS devices ? |
|
@simbit18 I don't have an Intel Mac though. This will work on M1 Mac? |
|
macos-14 Today, GitHub is excited to announce the launch of a new M1 macOS runner! |
|
Thanks @simbit18! On my Mac Mini M2 Pro, it fails while building gperf: https://gist.github.com/lupyuen/9e49ad8f91e2f2e9b76c41eb583664d9 |
|
@lupyuen maybe related to this ? I see this is a common problem :) possible solution |
|
I just restarted the job so it will pick up the fix from apache/nuttx-apps#2829. And it won't run all 6 hours :-) |
|
OK making good progress! I changed this in tools/ci/platforms/darwin.sh add_path() {
PATH=$1:${PATH}
## TODO: Remove Homebrew ar from PATH
PATH=$(
echo $PATH \
| tr ':' '\n' \
| grep -v "/opt/homebrew/opt/make/libexec/gnubin" \
| grep -v "/opt/homebrew/opt/coreutils/libexec/gnubin" \
| grep -v "/opt/homebrew/opt/binutils/bin" \
| tr '\n' ':'
)
echo "**** PATH=$PATH" | tr ':' '\n'
## Should show /usr/bin/ar
which ar
}Now it fails while installing Cython: https://gist.github.com/lupyuen/012515d912b8524d29a01793a256b485 |
@lupyuen for this problem i try to test on runner macos-14 |
|
Thank you so much! I see 3 different styles of |
|
this is what I use locally (msys2 and Alpine) for create a virtual environment in Python the problem is the path if you change it it should work on macos-14 |
|
If you change path the test on github macos-14 is ok workflow https://github.com/simbit18/nuttx_test_pr/actions/runs/11740209647/job/32706315729 we need to define a path that is ok for both (github and real macOS devices) |
|
I don't quite understand what the code below is doing. PIP_USER and PYTHONUSERBASE seem to be interfering with the venv? This runs OK: python_tools() {
#### TODO: Previously failed to install Cython
# # Python User Env
# export PIP_USER=yes
# export PYTHONUSERBASE=${NUTTXTOOLS}/pylocal
# echo "export PIP_USER=yes" >> "${NUTTXTOOLS}"/env.sh
# echo "export PYTHONUSERBASE=${NUTTXTOOLS}/pylocal" >> "${NUTTXTOOLS}"/env.sh
# add_path "${PYTHONUSERBASE}"/bin
# if [ "X$osarch" == "Xarm64" ]; then
# python3 -m venv --system-site-packages /opt/homebrew
# fi
#### TODO: Now it installs Cython OK!
python3 -m venv .venv
source .venv/bin/activate
# workaround for Cython issue
# https://github.com/yaml/pyyaml/pull/702#issuecomment-1638930830
pip3 install "Cython<3.0" |
|
CI Build on Mac M2 Pro works OK yay! (with the above fixes) $ ./cibuild.sh -i -c -A -R testlist/macos.dat
...
====================================================================================
Configuration/Tool: stm32f4discovery/nsh,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2024-11-08 19:04:16
------------------------------------------------------------------------------------
Cleaning...
Configuring...
Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
Building NuttX...https://gist.github.com/lupyuen/6d25cfa16b8920b515dcc14835e7a479 Here's the modified script: darwin.sh.txt |
This should be used for caches on github
|
|
OK the CI Build is done! https://gist.github.com/lupyuen/6d25cfa16b8920b515dcc14835e7a479 The downloading wasn't that slow, and the GitHub Cache won't work on my Mac anyway. I'll probably disable that chunk of code when I run my Mac Build Farm :-) |
|
I'm super impressed: arm-01 will actually build on Mac M2 Pro! $ ./cibuild.sh -i -c -A -R testlist/arm-01.dat
Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
Building NuttX...
Normalize pcduino-a10/nshhttps://gist.github.com/lupyuen/e2babbcad9a102fcb002ca6dcf361895 Build for arm-01 completes in 1 hour. That's the same speed as GitHub Actions! |
|
FYI I'm running the script below to patch
The patched When we change the Toolchains from x86_64 macOS to Arm64 macOS:
https://github.com/lupyuen/nuttx-build-farm/blob/main/patch-ci-macos.sh ## How to run CI Build:
## rm -rf NUTTX_PARENT_FOLDER/tools
## ./cibuild.sh -i -c -A -R testlist/macos.dat
## ./cibuild.sh -i -c -A -R testlist/arm-01.dat
set -e # Exit when any command fails
set -x # Echo commands
## Create the Temp Folder
tmp_dir=/tmp/macos-build-farm
rm -rf $tmp_dir
mkdir $tmp_dir
## We shall rewrite darwin.sh
file=tools/ci/platforms/darwin.sh
tmp_file=$tmp_dir/darwin.yml
## Search and replace in the file
function rewrite_file {
cat $file \
| sed "s/$search/$replace/g" \
>$tmp_file
mv $tmp_file $file
}
## Change: basefile=arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi
## To: basefile=arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi #### TODO
search='-darwin-x86_64-arm-none-eabi'
replace='-darwin-arm64-arm-none-eabi #### TODO: We changed to Arm64 macOS'
rewrite_file
## Change: basefile=arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-aarch64-none-elf
## To: basefile=arm-gnu-toolchain-13.2.Rel1-darwin-arm64-aarch64-none-elf #### TODO
search='-darwin-x86_64-aarch64-none-elf'
replace='-darwin-arm64-aarch64-none-elf #### TODO: We changed to Arm64 macOS'
rewrite_file
## Change: basefile=xpack-riscv-none-elf-gcc-13.2.0-2-darwin-x64
## To: basefile=xpack-riscv-none-elf-gcc-13.2.0-2-darwin-arm64 #### TODO
search='-darwin-x64'
replace='-darwin-arm64 #### TODO: We changed to Arm64 macOS'
rewrite_file
## Change: basefile=xtensa-esp32-elf-12.2.0_20230208-x86_64-apple-darwin
## To: basefile=xtensa-esp32-elf-12.2.0_20230208-aarch64-apple-darwin #### TODO
search='-x86_64-apple-darwin'
replace='-aarch64-apple-darwin #### TODO: We changed to Arm64 macOS'
rewrite_file
## Change: add_path() {
## To: add_path() { ... } \r NOTUSED_add_path() {
search='^add_path() {'
replace=$(
cat <<'EOF' | tr '\n' '\r'
set -x # Echo commands
add_path() {
PATH=$1:${PATH}
#### TODO: We removed Homebrew ar from PATH
PATH=$(
echo $PATH \\
| tr ':' '\\n' \\
| grep -v "\/opt\/homebrew\/opt\/make\/libexec\/gnubin" \\
| grep -v "\/opt\/homebrew\/opt\/coreutils\/libexec\/gnubin" \\
| grep -v "\/opt\/homebrew\/opt\/binutils\/bin" \\
| tr '\\n' ':'
)
echo "**** PATH=$PATH" | tr ':' '\\n'
which ar ## Should show \/usr\/bin\/ar
}
NOTUSED_add_path() {
EOF
)
rewrite_file
## Change: python_tools() {
## To: NOTUSED_python_tools() {
search='^python_tools() {'
replace='NOTUSED_python_tools() {'
rewrite_file
## Change: # workaround for Cython issue
## To: } \r python_tools() { \r ... \r # workaround for Cython issue
search='^ # workaround for Cython issue'
replace=$(
cat <<'EOF' | tr '\n' '\r'
}
python_tools() {
#### TODO: We fixed the Python Environment
python3 -m venv .venv
source .venv\/bin\/activate
# workaround for Cython issue
EOF
)
rewrite_file
## Change \r back to \n
cat $file \
| tr '\r' '\n' \
>$tmp_file
mv $tmp_file $file
chmod +x $file(Called by run-job-macos.sh and run-ci-macos.sh) |
|
Hmmm macOS fails to build arm-05, arm-08 ... arm-13 because of clang. I'll have to disable the clang builds for our macOS Build Farm: https://gist.github.com/lupyuen/f5eb30774e7359b0bfd07100a07eb252#file-gistfile1-txt-L1374 |
|
you can download macOS arm clang from: |
|
Thanks! Need to figure out how to add this to our macOS CI Job 🤔 |
|
Our macOS Build Farm is up! 🎉 We skipped these CI Jobs for macOS: run-ci-macos.sh ## Repeat forever for All CI Jobs, excluding:
## arm-05: "nrf5340-dk/rpmsghci_nimble_cpuapp: apps/wireless/bluetooth/nimble/mynewt-nimble/nimble/host/services/gatt/src/ble_svc_gatt.c:174:9: error: variable 'rc' set but not used"
## arm-07: "ucans32k146/se05x: mv: illegal option -- T"
## xtensa-02: "xtensa-esp32s2-elf-gcc: Command not found"
## arm64-01: "imx93-evk/bootloader: ld: library not found for -lcrt0.o"
## sim-01, 02, 03: "clang: error: invalid argument 'medium' to -mcmodel="
## other: "micropendous3/hello: make: avr-objcopy: Bad CPU type in executable"
for (( ; ; )); do
for job in \
arm-01 arm-02 arm-03 arm-04 \
arm-06 arm-08 arm-09 arm-10 \
arm-11 arm-12 arm-13 arm-14 \
risc-v-01 risc-v-02 risc-v-03 \
risc-v-04 risc-v-05 risc-v-06 \
xtensa-01 \
x86_64-01
do
## Run the CI Job and find errors / warnings
run_job $job
clean_log
find_messagesAnd we skipped all clang targets: run-job-macos.sh ## Exclude clang Targets from macOS Build, because they will fail due to unknown arch
## "/arm/lpc54xx,CONFIG_ARM_TOOLCHAIN_CLANG"
## https://github.com/apache/nuttx/pull/14691#issuecomment-2466518544
tmp_file=$tmp_dir/rewrite-testlist.dat
for file in nuttx-patched/tools/ci/testlist/*.dat; do
grep -v "CLANG" \
$file \
>$tmp_file
mv $tmp_file $file
done
## Run the CI Job in "nuttx-patched"
## ./cibuild.sh -i -c -A -R testlist/macos.dat
## ./cibuild.sh -i -c -A -R testlist/arm-01.dat
pushd nuttx-patched/tools/ci
(
./cibuild.sh -i -c -A -R testlist/$job.dat \
|| echo '***** BUILD FAILED'
)
popd |
|
hi @lupyuen I made some changes see branch added the darwin_arm64.sh shell script only for macOS Apple Silicon (macos-14) updated the toolchains for macOS on Apple Silicon
these will lighten your patch |
|
Thanks @simbit18, yep just go ahead and create the PR :-) |



Summary
Now you can use any of these runners
macos-13
https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md
or
macos-14 (arm64)
https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
added autoconf
needed to build kconfig_frontends on macos-14
bloaty
speeded build with cmake + ninja
if we upgrade to macos-14 we need to remember to clear the caches (macOS-tools-xxxxxxxx) first
https://github.com/apache/nuttx/actions/caches
Impact
Impact on user: No changes to user-facing functionality
Impact on build: Build process remains the same
Testing
tested only on github workflow with only [macos] because sim01, sim02, sim03 are broken !!!
macos-13
github macos-13
macos-14
github macos-14