Skip to content

Commit f53db6a

Browse files
committed
patch allows user to define 2 additional, optional parameters in the preferences.txt file.
the parameters allow to tweak the default linker settings by injecting custom options to the avr-gcc command line. the parameters: * build.linker_options - specified options will *replace* the default '-Wl,--gc-sections' options * build.linker_additional_options - options will *replace* the default '-lm' (at the end of the command line) fine tuning these variables allows one to link against the float-enabled versions of printf and scanf. has been tested on windows XP, with the following options set in the user's preferences.txt: <pre> build.linker_options=-Wl,-u,vfprintf,-u,vfscanf,--gc-sections build.linker_additional_options=-lprintf_flt -lscanf_flt -lm </pre>
1 parent 19f513b commit f53db6a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/src/processing/app/debug/Compiler.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ public boolean compile(Sketch sketch,
196196
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
197197
avrBasePath + "avr-gcc",
198198
"-Os",
199-
"-Wl,--gc-sections"+optRelax,
199+
(Preferences.get("build.linker_options")!= null ? Preferences.get("build.linker_options")+optRelax :
200+
"-Wl,--gc-sections"+optRelax),
200201
"-mmcu=" + boardPreferences.get("build.mcu"),
201202
"-o",
202203
buildPath + File.separator + primaryClassName + ".elf"
@@ -208,8 +209,14 @@ public boolean compile(Sketch sketch,
208209

209210
baseCommandLinker.add(runtimeLibraryName);
210211
baseCommandLinker.add("-L" + buildPath);
211-
baseCommandLinker.add("-lm");
212-
212+
if (Preferences.get("build.linker_additional_options") != null) {
213+
for (String addopt : Preferences.get("build.linker_additional_options").split(" ")) {
214+
baseCommandLinker.add(addopt);
215+
}
216+
} else {
217+
baseCommandLinker.add("-lm");
218+
}
219+
213220
execAsynchronously(baseCommandLinker);
214221

215222
List baseCommandObjcopy = new ArrayList(Arrays.asList(new String[] {

0 commit comments

Comments
 (0)