`postobjcopy` patterns on macOS fail with spaces in build path
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- bash
- Domain
- build-system, cli
Research direction
Start in platform.txt at the recipe.hooks.objcopy.postobjcopy patterns around lines 129–135 and compare the Linux and macOS commands with the Windows quoting. Reproduce an arduino-cli compile using a build path containing spaces, then verify the post-build avr-objdump and avr-nm steps complete successfully on the affected platforms.
Written by the indexing model from the issue text.
Description
Details
Hey there! Thank you for your work on this repo. I ran into an issue when trying to compile for an ATTiny 1616. After some sleuthing, here's my best guess as to what's going on:
On macOS, the recipe.hooks.objcopy.postobjcopy patterns in platform.txt wrap commands in bash -c "..." but leave the .elf and output file paths unquoted inside the string. When the build path contains spaces (e.g. a project inside ~/Foo Bar/), the shell splits the path on whitespace and avr-objdump/avr-nm fail with No such file or directory.
From what I can tell, the Windows pattern already quotes paths correctly using "...". The macOS and Linux patterns do not.
Steps to reproduce:
NOTE: this does not impact compilation from Arduino studio. This only seems to come into effect when called from the CLI like arduino-cli compile --profile ATtiny1616 -v --jobs 0 --build-path <path>. I'm actually not doing this directly, but an IDE extension I'm using does call the CLI in this manner for whatever reason.
- Install
megaTinyCore:megaavr 2.6.12 - Use megaTinyCore with any sketch whose build path contains spaces
- Compile via the CLI. the core files build successfully but the post-build step fails with exit status 1
- Verbose output shows:
avr-objdump-related no such file errors - See the script reports
Error during build: exit status 1
Potential fix
I've applied this fix locally and it seems to work but this is far from my area of expertise:
(platform.txt, lines 129–130, 134–135):
-recipe.hooks.objcopy.postobjcopy.1.pattern.linux=bash -c "{compiler.path}{compiler.objdump.cmd} {compiler.objdump.flags} {build.path}/{build.project_name}.elf > {build.path}/{build.project_name}.lst"
-recipe.hooks.objcopy.postobjcopy.1.pattern.macosx=bash -c "{compiler.path}{compiler.objdump.cmd} {compiler.objdump.flags} {build.path}/{build.project_name}.elf > {build.path}/{build.project_name}.lst"
+recipe.hooks.objcopy.postobjcopy.1.pattern.linux=bash -c '{compiler.path}{compiler.objdump.cmd} {compiler.objdump.flags} "{build.path}/{build.project_name}.elf" > "{build.path}/{build.project_name}.lst"'
+recipe.hooks.objcopy.postobjcopy.1.pattern.macosx=bash -c '{compiler.path}{compiler.objdump.cmd} {compiler.objdump.flags} "{build.path}/{build.project_name}.elf" > "{build.path}/{build.project_name}.lst"'
-recipe.hooks.objcopy.postobjcopy.2.pattern.linux=bash -c "{compiler.path}{compiler.nm.cmd} {compiler.nm.flags} {build.path}/{build.project_name}.elf > {build.path}/{build.project_name}.map"
-recipe.hooks.objcopy.postobjcopy.2.pattern.macosx=bash -c "{compiler.path}{compiler.nm.cmd} {compiler.nm.flags} {build.path}/{build.project_name}.elf > {build.path}/{build.project_name}.map"
+recipe.hooks.objcopy.postobjcopy.2.pattern.linux=bash -c '{compiler.path}{compiler.nm.cmd} {compiler.nm.flags} "{build.path}/{build.project_name}.elf" > "{build.path}/{build.project_name}.map"'
+recipe.hooks.objcopy.postobjcopy.2.pattern.macosx=bash -c '{compiler.path}{compiler.nm.cmd} {compiler.nm.flags} "{build.path}/{build.project_name}.elf" > "{build.path}/{build.project_name}.map"'
The fix switches the outer bash -c delimiter to single quotes (so the inner double quotes are passed literally to the shell rather than being interpreted by arduino-cli's template expansion), and applies the same fix to Linux since it has the identical bug.
If that passes the sniff test, please let me know and I'll open a PR!
Thanks again
- Dominant language
- C
- Stars
- 681
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SpenceKonde/megaTinyCore
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
SpenceKonde/megaTinyCore#1271 ·
-
ATtiny 2 series RTC prescaler value incorrect, millis() and delay() run 32X faster than nominal. Open
Difficulty 1/5 Under an hour Newbie friendliness 35/100
SpenceKonde/megaTinyCore#1288 · 3 comments · 1 reaction ·
-
Difficulty 1/5 Under an hour Newbie friendliness 10/100
SpenceKonde/megaTinyCore#1287 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
SpenceKonde/megaTinyCore#1283 · 1 comment · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
SpenceKonde/megaTinyCore#1280 · 1 comment ·
All issues in SpenceKonde/megaTinyCore
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100