Skip to content
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

Pass build flags to the specific scope #2144

Open
ivankravets opened this issue Feb 18, 2019 · 4 comments
Open

Pass build flags to the specific scope #2144

ivankravets opened this issue Feb 18, 2019 · 4 comments

Comments

@ivankravets
Copy link
Member

Allow passing build flags to the specific scope. See https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-flags

Example,

[env:myenv]
board = ...
build_flags =
    ; Only for C files
    CFLAGS: -Wno-old-style-declaration
    ; Only for CPP files
    CXXFLAGS: -fexceptions
    LINKFLAGS: -u __cxa_guard_dummy -u ld_include_panic_highint_hdl 
@positron96
Copy link

I wanted to chime in and say that that would be a very useful feature.
Too often I find myself in a need to add extra py script overcome pio's automatic passing of flags to gcc/g++/ld.
E.g. this: #594

@tai
Copy link

tai commented Jan 22, 2023

I'd like to upvote this - it's really cumbersome that I need to prepare an external extra_script= whenever I want to specify some linker flags. Embedded development frequently requires custom linker flags (linker script, etc), so it should be easy as build_flags= to specify one.

The most recent one I was caught is that passing build_flags="-g" does not actually include full debug_info in generated ELF file (AVR target fails to include reference to source/symbol info in included debuginfo). I had to use extra_script= to pass "-g" and get avr-objdump -CDS working. "-g" options is just so common that I feel this should be much easier.

@mrv96
Copy link

mrv96 commented Aug 4, 2023

I'd like to upvote this too

@Ariakenom
Copy link

It seems like this is the intended solution for these issues so I'll make a comment here.
#594
#843

Is it not a bug that pio only passes -Wl build_flags to the linker when there are more flags that are for linking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants