Skip to content

Commit 2d7e3d1

Browse files
authored
Fix -DARDUINO_LIB_DISCOVERY_PHASE automatic flag incompatiblity in some rare circumstances (#838)
* Revert "Add macro -DARDUINO_LIB_DISCOVERY_PHASE during lib discovery phase (#633)" This reverts commit 985b2c9. * Set {build.library_discovery_phase} to 1 during lib discovery Previously we used to add `-DARDUINO_LIB_DISCOVERY_PHASE` to the gcc command line but this produced some incompatiblity with compilers using non-standard `-d` flag instead of `-D`: #633 (comment)
1 parent 858cda3 commit 2d7e3d1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: legacy/builder/gcc_preproc_runner.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath *
5757

5858
func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) (*exec.Cmd, error) {
5959
properties := ctx.BuildProperties.Clone()
60+
properties.Set("build.library_discovery_phase", "1")
6061
properties.SetPath(constants.BUILD_PROPERTIES_SOURCE_FILE, sourceFilePath)
6162
properties.SetPath(constants.BUILD_PROPERTIES_PREPROCESSED_FILE_PATH, targetFilePath)
6263

@@ -77,8 +78,6 @@ func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths
7778
// to create a /dev/null.d dependency file, which won't work.
7879
cmd.Args = utils.Filter(cmd.Args, func(a string) bool { return a != "-MMD" })
7980

80-
cmd.Args = append(cmd.Args, "-DARDUINO_LIB_DISCOVERY_PHASE")
81-
8281
return cmd, nil
8382
}
8483

Diff for: legacy/builder/setup_build_properties.go

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error {
6767
buildProperties.Set("build.fqbn", ctx.FQBN.String())
6868
buildProperties.Set("ide_version", ctx.ArduinoAPIVersion)
6969
buildProperties.Set("runtime.os", properties.GetOSSuffix())
70+
buildProperties.Set("build.library_discovery_phase", "0")
7071

7172
if ctx.OptimizeForDebug {
7273
if buildProperties.ContainsKey("compiler.optimization_flags.debug") {

0 commit comments

Comments
 (0)