Skip to content

Fix linking failure for space in path in PlatformIO builder scripts #6464

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 9 commits into from
Mar 28, 2022

Conversation

maxgerhardt
Copy link
Contributor

@maxgerhardt maxgerhardt commented Mar 22, 2022

By completing this PR sufficiently, you help us to improve the quality of Release Notes

Checklist

  1. Please provide specific title of the PR describing the change, including the component name (eg. „Update of Documentation link on Readme.md“)
  2. Please provide related links (eg. Issue, other Project, submodule PR..)
  3. Please check Contributing guide

This entire section above can be deleted if all items are checked.


Summary

This PR modifies the linker flag that produces the .map file for the project. For projects which contain spaces, this previously resulted in an error (#6463).

Impact

Fixes compilation for projects that contain spaces in their path or enviornment name (in platformio.ini, [env:xxx]). The .map file will however now be the default firmware.map (or whatever PROGNAME is set to if modified by custom scripts).

The usage of basename() with environment subtition led to extremely weird bugs. This is fix here has been tested to work on both Windows on Linux. For the 'extreme case' of spaces in the project path and environment name, it correctly generates the flag on Windows

-Wl,-Map="C:\Users\Max\temp\Test Project With Spaces\.pio\build\esp32dev with spaces\firmware.map" 

and on Linux

-Wl,-Map="/home/max/Test Project with Spaces/.pio/build/esp32dev with spaces/firmware.map" 

Which would previously error out.

Related links

See #6463.

@CLAassistant
Copy link

CLAassistant commented Mar 22, 2022

CLA assistant check
All committers have signed the CLA.

@maxgerhardt maxgerhardt changed the title Hotfix linking failure for space in path Hotfix linking failure for space in path in PlatformIO builder scripts Mar 22, 2022
@maxgerhardt
Copy link
Contributor Author

P.S.: This is a hotfix intended to get it working / unblock people, a nicer fix would depend on platformio/platformio-core#4205.

Please wait a bit so that maybe a cleaner fix can be found there before merging.

@mcspr
Copy link

mcspr commented Mar 23, 2022

As mentioned in the platformio/platformio-core#4205 (comment)
Have you tried

    '-Wl,-Map',
    '-Wl,"${BUILD_DIR}/${PROGNAME}.map"'

in the LINKFLAGS?

@maxgerhardt
Copy link
Contributor Author

This would likely be a cleaner and better fix, I will try in a moment.

@maxgerhardt
Copy link
Contributor Author

Yes, this produces the correct flag

 -Wl,-Map -Wl,"C:\Users\Max\temp\Test Project With Spaces\.pio\build\esp32dev/firmware.map" 

and the file is created at the proper place.

Still a difference from the what the original script would do with Test Project With Spaces.map as filename, but I think this is way better..

@maxgerhardt
Copy link
Contributor Author

Wow no, this actually does not work. On Linux where the path seperator is /, it produces

-Wl,-Map "-Wl, "/home/max/Test" Project with Spaces/.pio/build/esp32dev with spaces/firmware.map" 

there is that dead dreaded " in the middle of the path again and the whole quoting of the argument. This is more complicated than I thought.

@maxgerhardt
Copy link
Contributor Author

The code '-Wl,-Map="%s"' % join("${BUILD_DIR}", "${PROGNAME}.map") works however.. I'll leave it at that.

@maxgerhardt maxgerhardt changed the title Hotfix linking failure for space in path in PlatformIO builder scripts Fix linking failure for space in path in PlatformIO builder scripts Mar 23, 2022
@mcspr
Copy link

mcspr commented Mar 23, 2022

Strange, I was testing with the exact configuration where there were spaces in both project and env name :/

-Wl,-Map -Wl,"/home/max/dev/espurna test dir/code/.pio/build/esp8266 1m git base/firmware.map"

was created just fine in the wsl env

@maxgerhardt
Copy link
Contributor Author

maxgerhardt commented Mar 23, 2022

And that was with pio upgrade --dev latest core? (+ pio platform update latest all other packages)?

PS my reference platformio.ini is

[env:esp32dev with spaces]
platform = https://github.com/Jason2866/platform-espressif32.git
board = esp32dev
framework = arduino

@mcspr
Copy link

mcspr commented Mar 23, 2022

Just made sure that I fetched all of the above and did a pio upgrade --dev
Plus, the change I mentioned for the $framework/tools/platformio-build-esp32.py

-Wl,-Map -Wl,"/home/max/dev/esp32 test dir/.pio/build/esp32dev with spaces/firmware.map"

🤷

@Jason2866
Copy link
Collaborator

Jason2866 commented Mar 23, 2022

I will do a build with this changes and update

platform = https://github.com/Jason2866/platform-espressif32.git

So more people can test

EDIT: repo is updated

@maxgerhardt
Copy link
Contributor Author

maxgerhardt commented Mar 23, 2022

This is too magical. Now I changed the line back to what @mcspr suggeted, did a pio run -t clean && pio run and now the code works too and generates

 -Wl,-Map -Wl,"/home/max/Test Project with Spaces/.pio/build/esp32dev with spaces/firmware.map"

Wow... I have really no idea now.

Edit: Works on Windows too.

But in any case, the current version of the PR with the two arguments combined also works equivalently.. 🤷

@Jason2866
Copy link
Collaborator

@maxgerhardt The fix works fine. 👍 Our map move and naming Platformio script is still working 🤞

@github-actions
Copy link
Contributor

github-actions bot commented Mar 28, 2022

Unit Test Results

0 files  0 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0

Results for commit c686b66.

♻️ This comment has been updated with latest results.

@me-no-dev
Copy link
Member

@maxgerhardt can you please confirm that all is good?

@Jason2866
Copy link
Collaborator

@maxgerhardt @me-no-dev I have included this PR (with S3) 5 days ago and we have no negative feedback from users when compiling Tasmota with this change.
Tested with spaces in path. The error happend before is fixed.

Copy link
Collaborator

@Jason2866 Jason2866 left a comment

Choose a reason for hiding this comment

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

Tested and verified

@me-no-dev me-no-dev merged commit 51040cc into espressif:master Mar 28, 2022
@me-no-dev
Copy link
Member

Thanks guys :) Merged!

Jason2866 referenced this pull request Mar 28, 2022
esp-dl: master d949350
esp-dsp: master 07aa7b1
esp-rainmaker: master 5af4f64
esp-sr: master d05cf97
esp32-camera: master 86a4951
esp_littlefs: master 5f0d614
@Jason2866
Copy link
Collaborator

@me-no-dev Latest commit 31510f4 did revert this PR

@me-no-dev
Copy link
Member

the lib-builder must have grabbed arduino before merge. will reapply

@Jason2866
Copy link
Collaborator

@Jason2866
Copy link
Collaborator

Mhh, i have to look if this PR ever was in a build.

@me-no-dev
Copy link
Member

Jason2866 added a commit to Jason2866/esp32-arduino-lib-builder that referenced this pull request Mar 29, 2022
me-no-dev pushed a commit to espressif/esp32-arduino-lib-builder that referenced this pull request Mar 29, 2022
me-no-dev added a commit that referenced this pull request Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants