PlatformIO Community

Cant remove "-fno-rtti" with pre: script on STM32

I want to use FakeIt for mocking, and run the executable on my board. FakeIt uses typeid() and dynamic casts, and even exceptions, so it won’t compile with the default flags. I don’t want to define these “globally” in platformio.ini, so I’ve decided to use a pre: script to remove/add flags, but I can’t remove “-fno-rtti”.
Here’s what I’ve tried:

if "test" in env.GetBuildType():
  env.Append(CPPDEFINES=["TESTING",]) # not important


The first two have no effect, and the last one says, that there is no such item in the list.

When i do build_unflags = ...-fno-rtti in platformio.ini, it works.

I’m not sure if I’m doing something wrong, but as far as I can tell, this should work as intended.

The project can be found on Github

The releavant contents of platformio.ini

extra_scripts = 

Reminds me of Force RTTI from library? - #23 by cziter15, can you try that, possibly in a post script?

1 Like

Yep, this was working very good after fixes, however now not forcing RTTI in my lib.

Made it a post: script, also upgraded pio to --dev, but still, no luck. I modified my script, and added a env.Dump(), after doing the “remove”. Weird thing is, there is no -fno-rtti in the Dump, but it’s still there while building. I’ve updated the git branch with the changes, and also included an out.txt file, with the output of command: pio test -vvv --environment debug 1> out.txt 2> build_errs.txt. BTW the project should be buildable out of the box, if you are interested in debugging. I can also try to create a minimal version, to reproduce this error.

I’m not familiar with pio scripting, and I’m just gluing stuff together. Should I do env.AddPreAction()?

Here are my changes:


extra_scripts = 

env = DefaultEnvironment()

if "test" in env.GetBuildType():
    print("Removing -fnortti -fno-exceptions")

Please also take a look at out.txt and build_errs.txt

It’s as if the CXXFLAGS were modified after running the script