:flags: not working

462 views
Skip to first unread message

alan....@gmail.com

unread,
May 7, 2013, 6:21:07 AM5/7/13
to throwth...@googlegroups.com
I'm trying to specify :flags: in yaml such as follows-

:flags:
 
:test:
   
:compile:
     
:*:
       
- -g

The -g option gets passed through as last element of args to build_command_line in tool_executor but never makes it out to the command line.  I think it might be a problem in expandify_element but to be honest, I can't track what the code is doing here as it is not commented well.

Thanks,
Alan

mateja...@gmail.com

unread,
Feb 14, 2014, 11:12:50 AM2/14/14
to throwth...@googlegroups.com, alan....@gmail.com
I'm seeing the same behavior. My solution in the mean time has been to create custom compiler/linker configs that reflect the default configs as closely as possible with the addition of flags.

Has anyone had a chance to track down this issue, please?

Thanks,

M

laurence.desch...@gmail.com

unread,
Oct 10, 2015, 9:13:05 AM10/10/15
to ThrowTheSwitch Forums, alan....@gmail.com
I am still seeing the same behavior with the current version (gem install 0.18.0).
I have a project.yml:
---
:project:
 
:use_exceptions: FALSE
 
:use_test_preprocessor: TRUE
 
:use_auxiliary_dependencies: TRUE
 
:build_root: build
 
:release_build: TRUE
 
:test_file_prefix: test_

:release_build:
 
:output: ELE440-Lab2.exe
 
:use_assembly: FALSE

:environment:

:flags:
 
:release:
   
:compile:
     
:*:
       
- -std=c++11
       
- -O0
       
- -Wall

:extension:
 
:source: .cpp
 
:executable: .exe

:paths:
 
:test:
   
- +:test/**
    - -:test/support
  :source:
    - src/**
  :support:
    - test/support

:defines:
  :commmon: &common_defines []
  :test:
    - *common_defines
    - TEST
  :test_preprocess:
    - *common_defines
    - TEST

:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :plugins:
    - :ignore
    - :callback
  :treat_as:
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    int8:     INT8

    bool:     UINT8

:plugins:
  :load_paths:
    - vendor/ceedling/plugins
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
...
Enter code here...
Does anyone have a suggestion to pass simple arguments such as "-std=c++11" to Ceedling? (The solution of explicitly defining the default values with minor changes is very error-prone...)


Mike Karlesky

unread,
Oct 10, 2015, 11:07:05 AM10/10/15
to throwth...@googlegroups.com

I went back to the original thread (that I do not recall reading previously), but I'm not quite clear on what exactly the problem is. Can you walk us through the specifics?

--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To post to this group, send email to throwth...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/throwtheswitch/f3ae0fd7-1250-4075-abc1-00283dc32152%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

laurence.desch...@gmail.com

unread,
Oct 10, 2015, 12:42:25 PM10/10/15
to ThrowTheSwitch Forums
No problem, here is what I got:

0. Setup is Windows 10 64bit with TDM-GCC 64 5.1.0 (link) (suggested by codelite)
I use PowerShell or SublimeText to invoke rake (both with same result)

1. Created a new project wit:
ceedling new projectName

2.
then copied my c++ source file in the /src folder made by ceedling.

3. Tried rake release and got result build succesful but with absolutely no warning (got many warning and some compilation error in the code, useful to see if the ceedling setup works as I can compare with my codelite parallel setup)

4. Found the extension,source parameter and changed it:
:extension:
 
:source: .cpp

5. Now I get compilation but get some warning from g++ complaining about my use of <cstdint>:
C:/Software/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

6.
I get those in Codelite too when I don't enable the -std=c++11 compilator option.

7.
I try this in my project.yml but I get the same previous error about C++ 2011 standard. Pointing me toward this parameters (flags) not working as I expected.
:flags:
 
:release:
   
:compile:
     
:*:
       
- -std=c++11

With codelite I call the exact same g++ compilation option as stated in my project.yml and I get past the C++2011 error. I could test a clean project but rake is quite mute when everything goes well including when he does detect anything to compile...

For the exact syntax of my project.yml you can refer to my previous post. Please let me know if you could benefit from more description.
Thanks you very much for your kind support.



On Saturday, 10 October 2015 11:07:05 UTC-4, Michael Karlesky wrote:

I went back to the original thread (that I do not recall reading previously), but I'm not quite clear on what exactly the problem is. Can you walk us through the specifics?

Mike Karlesky

unread,
Oct 29, 2015, 1:43:49 PM10/29/15
to throwth...@googlegroups.com

So very sorry for the slow response!

Probably our best bet is to work backwards. It'd be great to see how Ceedling is populating the command line for your compilation. The best way to do this is to enable an appropriate level of verbosity (level 4—obnoxious). See the documentation for Ceedling (page 4) for more on this.

I don't immediately recall idiosyncrasies of using the '*' option (honestly, I don't recall the '*' hardly at all!). It may have something to do with that. But my gut says it may simply be there is some YAML and string funny business going on in that flag. You may simply need to quote it:

:flags:
 
:release:
   
:compile:
     
:*:
       
- '-std=c++11' #note enclosing single quote marks




laurence.desch...@gmail.com

unread,
Nov 2, 2015, 7:30:08 PM11/2/15
to ThrowTheSwitch Forums
Hey Michael,

Thanks again for your answer,

I sadly deleted my non-working project as it was a school work that needed to be done as soon as possible.
No worries, I just recreated a similar setup this time with a simple main.cpp:
/*--------------------------------- +
|    INCLUDE                            |
+ ---------------------------------*/

/* ==== Lib ==== */
#include <cstdio>
#include <cstdint>
#include <iostream>     /* Needed for debuging */
/* ================= */

using namespace std;

/*--------------------------------- +
|    GLOBAL                            |
+ ---------------------------------*/


/*--------------------------------- +
|    PROTOTYPES                        |
+ ---------------------------------*/

void printTest(char * string);

/*--------------------------------- +
|    MAIN                            |
+ ---------------------------------*/

int32_t main
(int32_t argc, char** argv)
{
    printTest
("Testing One Two One Two");

   
exit(0);
}

/*--------------------------------- +
|    FUNCTION                        |
+ ---------------------------------*/

void printTest(char * string)
{
    printf
(string);
}

I tried the '-std=c++1' option but I get the same result with our without this entire block:

:flags:
 
:release:
   
:compile:
     
:*:
       
- '-std=c++11'

Then I used powershell and called "rake verbosity[4] release" and got this:
PS C:\Users\Laurence\Desktop\ceedlingTest\ceedlingTestingCpp> rake release


Release build 'project.out'
---------------------------
Compiling main.cpp...
In file included from C:/Software/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/cstdint:35:0,
                 
from src/main.cpp:14:

C
:/Software/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

 
#error This file requires compiler and library support for the \
 
^
src
/main.cpp:32:1: error: 'int32_t' does not name a type
 int32_t main
(int32_t argc, char** argv)
 
^
ERROR
: Shell command failed.
> Shell executed command:
'gcc.exe -I"src" -DGNU_COMPILER -c "src/main.cpp" -o "build/release/out/c/main.o"'
> And exited with status: [1].

rake aborted
!

C
:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/generator.rb:97:in `rescue in generate_object_file'
C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/generator.rb:101:in `
generate_object_file'
C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/rules_release.rake:26:in `block in <top (required)>'

C
:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/task_invoker.rb:85:in `block in invoke_release_objects'
C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/par_map.rb:10:in `
block (2 levels) in par_map'
ShellExecutionException: ShellExecutionException
C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/tool_executor.rb:74:in `exec'

C
:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/generator.rb:94:in `generate_object_file'
C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/rules_release.rake:26:in `
block in <top (required)>'
C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/task_invoker.rb:85:in `block in invoke_release_objects'

C
:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/par_map.rb:10:in `block (2 levels) in par_map'
Tasks: TOP => build/release/out/c/main.o
(See full trace by running task with --trace)

I don't seems to see any difference when using verbosity[0] or verbosity[4] :s

I have MinGW installed in parallel to TDM-GCC maybe I should remove TDM-GCC? (it is recommend by codelite that's why I have installed it)

Mike Karlesky

unread,
Nov 5, 2015, 4:46:47 PM11/5/15
to throwth...@googlegroups.com

I just looked through the Ceedling documentation (but not yet the code). You may have found a bug. The '*' in the flags config section should readily add the language specification flag to the compilation of main.cpp (and all other files not otherwise configured with individual compilation flags), but it clearly does not.

What happens if you modify your config to the following?

:flags:
 
:release:
   
:compile:
      :main:
        - '-std=c++11'



--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To post to this group, send email to throwth...@googlegroups.com.

laurence.desch...@gmail.com

unread,
Nov 5, 2015, 5:34:44 PM11/5/15
to ThrowTheSwitch Forums
I get the same error as before.
I tried with and without the single-quote '
I tried also :
:flags:
 
:release:
   
:*:
      :*:
        - '-std=c++11'
for kicks, but get the same error still.
Anything I can do to help more?

Mike Karlesky

unread,
Nov 6, 2015, 7:06:47 AM11/6/15
to throwth...@googlegroups.com

Let's try your original config but remove the '=' and '+'s from the flag. I wonder if the form of the string is breaking something in a parser along the way (i.e. the equal sign is getting treated specially somehow and throwing a wrench in the processing of the config value). This modified flag won't allow you to compile successfully, but let's see if we can at least get it to show up on the command line.

A second option is to print out what Ceedling has built up internally as a data structure from the config file. I believe one of the following print statements added to your own rakefile should produce something of interest (not sure which one if either will work):

puts (FLAGS_RELEASE)
puts (FLAGS_RELEASE_*)



--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To post to this group, send email to throwth...@googlegroups.com.

laurence.desch...@gmail.com

unread,
Nov 7, 2015, 11:08:58 AM11/7/15
to ThrowTheSwitch Forums
I get the same error (same as before) with:
:flags:
 
:release:
   
:compile:
     
:main:
       
- '-stdc11'

With or without single-quotes:
blablabla....

ERROR
: Shell command failed.
> Shell executed command:
'gcc.exe -I"src" -DGNU_COMPILER -c "src/main.cpp" -o "build/release/out/c/main.o"'
> And exited with status: [1].

rake aborted
!

blablabla
....

After adding (the other give me a syntax error)
puts (FLAGS_RELEASE)

I get that printed first
{:compile=>{:main=>["-stdc11"]}}
or
{:compile=>{:main=>["-std=c++11"]}}
In both test, there were no change with or without single-quote


Mike Karlesky

unread,
Nov 7, 2015, 2:58:34 PM11/7/15
to throwth...@googlegroups.com

Most peculiar. Looks very much like a bug. Or possibly the project has changed in some key ways since I last touched it, and it's now out of sync with the documentation. No matter what, it certainly something is broken or undocumented. I'll try to dig in.

--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To post to this group, send email to throwth...@googlegroups.com.

Karsten Bidstrup

unread,
Nov 8, 2015, 2:13:48 AM11/8/15
to ThrowTheSwitch Forums
Hi 

If I am understanding this discussion correctly then maybe the following could be of some help.

In the ceedling documentation in the tools section it is described how optional per-file flags can be added when you are creating your own custom tool setup with the ${4} item but only for compiler and linker. This is however NOT included when building with the defaults.rb in ceedling.
Adding "\"${4}\"".freeze for both default compiler and linker will insert the per-file flags correctly.

Changes to defaults.rb are marked with red.
DEFAULT_TEST_COMPILER_TOOL = {
  :executable => FilePathUtils.os_executable_ext('gcc').freeze,
  :name => 'default_test_compiler'.freeze,
  :stderr_redirect => StdErrRedirect::NONE.freeze,
  :background_exec => BackgroundExec::NONE.freeze,
  :optional => false.freeze,
  :arguments => [
    {"-I\"$\"" => 'COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'}.freeze,
    {"-I\"$\"" => 'COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'}.freeze,
    {"-D$" => 'COLLECTION_DEFINES_TEST_AND_VENDOR'}.freeze,
    "-DGNU_COMPILER".freeze,
    "-g".freeze,
    "-c \"${1}\"".freeze,
    "-o \"${2}\"".freeze,
    # gcc's list file output options are complex; no use of ${3} parameter in default config
    "\"${4}\"".freeze,
    ].freeze
  }

DEFAULT_TEST_LINKER_TOOL = {
  :executable => FilePathUtils.os_executable_ext('gcc').freeze,
  :name => 'default_test_linker'.freeze,
  :stderr_redirect => StdErrRedirect::NONE.freeze,
  :background_exec => BackgroundExec::NONE.freeze,
  :optional => false.freeze,
  :arguments => [
    "\"${1}\"".freeze,
    "-o \"${2}\"".freeze,
    "\"${4}\"".freeze,
    ].freeze
  }
This does however only help when compiling and linking. It seems there is no way at the moment to add the per-file flags for other tools like file and includes preprocessing except for setting up a custom tool section.

Maybe the modification of defaults.rb should be default behaviour? It would be nice if somehow per-file flags could be given in a general way for the other tools as well.


Den lørdag den 7. november 2015 kl. 20.58.34 UTC+1 skrev Michael Karlesky:

Most peculiar. Looks very much like a bug. Or possibly the project has changed in some key ways since I last touched it, and it's now out of sync with the documentation. No matter what, it certainly something is broken or undocumented. I'll try to dig in.

Mike Karlesky

unread,
Nov 8, 2015, 9:29:37 AM11/8/15
to throwth...@googlegroups.com

Just to clarify… did you need to control compilation on a per-file basis? The star feature is meant to provide a list of compile flags to all files not specified with per-file flag configuration. Something is certainly confusing about the per-file behaviors under discussion. If you specify the flags for all of compilation in the standard, more straightforward approach (below) what happens?


:flags:
 
:release:
   
:compile:
      - -std=c++11
      - -O0
      - -Wall


--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To post to this group, send email to throwth...@googlegroups.com.

laurence.desch...@gmail.com

unread,
Nov 8, 2015, 10:47:17 AM11/8/15
to ThrowTheSwitch Forums
When using:

:flags:
 
:release:
   
:compile:
      - -std=c++11

It correctly change the flag but I get the same error :
{:compile=>["-std=c++11"]}



Release build 'project.out'
---------------------------
Compiling main.cpp...
In file included from C:/Software/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/cstdint:35:0,
                 
from src/main.cpp:14:
C
:/Software/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 
#error This file requires compiler and library support for the \
 
^
src
/main.cpp:32:1: error: 'int32_t' does not name a type
 int32_t main
(int32_t argc, char** argv)
 
^

ERROR
: Shell command failed.
> Shell executed command:
'gcc.exe -I"src" -DGNU_COMPILER -c "src/main.cpp" -o "build/release/out/c/main.o"'
> And exited with status: [1].

rake aborted
!


C
:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/generator.rb:97:in `rescue in generate_object_file'
C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/generator.rb:101:in `
generate_object_file'

C:/Users/Laurence/Desktop/ceedlingTest/ceedlingTestingCpp/vendor/ceedling/lib/ceedling/rules_release.rake:26:in `block in <top (required)>'

laurence.desch...@gmail.com

unread,
Nov 8, 2015, 10:53:22 AM11/8/15
to ThrowTheSwitch Forums
I just tried both modification and the result is still the same error :S
I tested with:
:flags:
 
:release:
   
:compile:
     
:main:
       
- -std=c++11

I still don't see the "-std=c++11" in the verbose command printout:

ERROR: Shell command failed.
> Shell executed command:
'gcc.exe -I"src" -DGNU_COMPILER -c "src/main.cpp" -o "build/release/out/c/main.o"'
> And exited with status: [1].

rake aborted
!




Mike Karlesky

unread,
Nov 9, 2015, 9:36:53 PM11/9/15
to throwth...@googlegroups.com

I don't think the flag was actually changed! It's possible I'm reading your output snippet incorrectly, however. The line that quotes the gcc command line in the error message lacks the desired flag.

I've gone looking through the relevant code, and I tend to think there is a bug in there and/or a lack of documentation on how the :flags section is expecting to be configured.

I assume that if you copy/edit the command line Ceedling produces to include the desired flag and run it by hand that compilation succeeds. Is that so?


--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To post to this group, send email to throwth...@googlegroups.com.

laurence.desch...@gmail.com

unread,
Nov 9, 2015, 10:14:33 PM11/9/15
to ThrowTheSwitch Forums
Oh yes it does! Why didn't I think to test this before...
Output I get when calling gcc directly:
PS C:\Users\Laurence\Desktop\ceedlingTest\ceedlingTestingCpp> gcc.exe -I"src" -DGNU_COMPILER -c "src/main.cpp" -o "build/release/out/c/main.o" -std=c++11
src
/main.cpp: In function 'int32_t main(int32_t, char**)':
src
/main.cpp:34:37: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

  printTest
("Testing One Two One Two");

Still, as you say, Ceedling seems to not add the flag to the command line.

All this debugging is giving me hope though, I am starting to maybe kinda-understand those pesky toolchains! :)



On Monday, 9 November 2015 21:36:53 UTC-5, Michael Karlesky wrote:

I don't think the flag was actually changed! It's possible I'm reading your output snippet incorrectly, however. The line that quotes the gcc command line in the error message lacks the desired flag.

I've gone looking through the relevant code, and I tend to think there is a bug in there and/or a lack of documentation on how the :flags section is expecting to be configured.

I assume that if you copy/edit the command line Ceedling produces to include the desired flag and run it by hand that compilation succeeds. Is that so?

Mike Karlesky

unread,
Nov 10, 2015, 8:28:52 AM11/10/15
to throwth...@googlegroups.com

I've started working on Ceedling again. Resolving this flags issue is on my list.

In general, I've found that relying on unit testing in my projects increased my comfort with and understanding of toolchains many times over. Working with IDEs yields big gains in productivity but hides most of the magic of the toolchain involved. Getting tests to work and assembling build environments to run them is a sure way to increase one's knowledge of preprocessors, assemblers, compilers, and linkers.


Mike Karlesky

unread,
Nov 21, 2015, 10:15:17 AM11/21/15
to throwth...@googlegroups.com

Found and fixed the bug in the auxiliary flags processing. The feature itself was not broken but how it was hooked up to everything else was. Changes after it was added messed up proper wiring. It will be a little while until the next release as we work on various bugs, feature improvements, and badly needed documentation updates.

After having wrestled with the Ceedling code a bit, what you were trying to do was correct; Ceedling was simply broken. [For future reference if anyone should go searching the forum on this topic] The :flags feature is appropriate for inserting flags into the default gcc tool configuration without the larger step of creating a fully custom tool configuration. It's also appropriate for modifying compilation or linking flags for individual files in a build.

Reply all
Reply to author
Forward
0 new messages