Skip to content

Escaping linker arguments with quotes impossible to do correctly #4205

@maxgerhardt

Description

@maxgerhardt

What kind of issue is this?

  • PlatformIO Core.
    If you’ve found a bug, please provide an information below.

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Win10 x64

PlatformIO Version (platformio --version): 5.2.5

Description of problem

See espressif/arduino-esp32#6463 and forum.

The Arduino-ESP32 PlatformIO builder script tries to generate a .map file via the code (simplified)

env.Append(
   LINKFLAGS = [
    #... 
   '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map")))
   ]
)

However, PlatformIO or SCons seem to not be able to evaluate this correcty. If the project is e.g. in the path C:\Users\Max\temp\Test Project With Spaces, the generated commandline is

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

which as an extremely weird " at the last space in the project path ($BUILD_DIR presumably). As a result, the linker command is messed up and errors out, leaving users with a space in their username or project path unable to build Arduino-ESP32 2.0.2 firmwares.

How can the builder script be written so that the argument of the form -Wl,-Map="%s" is not further messed with by SCons or PlatformIO? The path escaping is already done here after all.

P.S.: Using -Wl,-Map followed by just the path does not seem to work, GCC seems to need it as one flag.

Steps to Reproduce

  1. Create a new folder with a space in it
  2. Execute pio init -b esp32dev in it
  3. Overwrite the platformio.ini with the one shown below
  4. Use the minimal C++ code shown below
  5. Attempt compilation

Actual Results

Linking failure due to weird double quoting.

Linking .pio\build\esp32dev\firmware.elf
xtensa-esp32-elf-g++: error: Project: No such file or directory
xtensa-esp32-elf-g++: error: With: No such file or directory
xtensa-esp32-elf-g++: error: Spaces.map: No such file or directory
*** [.pio\build\esp32dev\firmware.elf] Error 1
================[FAILED] Took 102.29 seconds ================

Expected Results

Succcessful compilation since the builder script correctly escapes paths with a potential space in it with quotes.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:arduino-esp32]
platform = https://github.com/Jason2866/platform-espressif32.git
board = esp32dev
framework = arduino
platform_packages = 
	framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32#master

Source file to reproduce issue:

#include <Arduino.h>
void setup() {}
void loop(){}

Additional info

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions