Skip to content

-D after -isystem is not applied by genreflex #13207

Open
@krasznaa

Description

@krasznaa

Check duplicate issues.

  • Checked for duplicates

Description

In order to try to silence some warnings coming from "externals" during dictionary generation for our classes (where our types would publicly depend on externals that themselves generate some warning), we just now started to teach our build system to provide include paths separately with -I and -isystem to the dictionary generation commands. (See: https://gitlab.cern.ch/atlas/atlasexternals/-/merge_requests/1028)

As it happens, this didn't solve our original issue with an older version of TBB, but that I did not manage to reproduce with a standalone example yet, so let's ignore that one for now. (You can find some more info in: https://gitlab.cern.ch/atlas/athena/-/merge_requests/64172)

But one issue that I found during this development is fairly easy to reproduce. It seems that one can not provide -isystem and -D command line options to genreflex in any order. Specifying -D flags after -isystem flags seems to not work.

Reproducer

Take the following file, called header.h:

#ifndef HEADER_H
#define HEADER_H

// Require the preprocessor definition.
#ifndef DO_NOT_FAIL
#error "Preprocessor definition not set!"
#endif

/// Dummy type
struct TypeWithDictionary {
  int foo;
};

#endif

With the following additional selection.xml file:

<lcgdict>
  <class name="TypeWithDictionary" />
</lcgdict>

With these two, I can run the following happily:

[bash][atspot01]:root-dict-isystem > genreflex header.h --select=selection.xml -o test_dict_success.cpp -D DO_NOT_FAIL -isystem /some/path
[bash][atspot01]:root-dict-isystem > head test_dict_success.cpp 
// Do NOT change. Changes will be lost next time file is generated

#define R__DICTIONARY_FILENAME test_dict_success
#define R__NO_DEPRECATION

/*******************************************************************/
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
[bash][atspot01]:root-dict-isystem >

But the following fails:

[bash][atspot01]:root-dict-isystem > genreflex header.h --select=selection.xml -o test_dict_fail.cpp -isystem /some/path -D DO_NOT_FAIL
input_line_7:8:2: error: "Preprocessor definition not set!"
#error "Preprocessor definition not set!"
 ^
Error: rootcling: compilation failure (./test_dict_fail5dde80a7de_dictUmbrella.h)
[bash][atspot01]:root-dict-isystem >

My guess is that -isystem in general is not taken correctly into account, but as I wrote in the description, I couldn't clearly demonstrate that thing just yet...

ROOT version

Tried 6.26.06 and v6-28-00-patches.

Installation method

Does not play a role here

Operating system

x86_64-ubuntu2004-gcc9-opt, x86_64-el9-gcc13-opt

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions