diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/target.exp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/target.exp b/lib/target.exp index d240007..c98fbd0 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -311,6 +311,11 @@ proc default_target_compile {source destfile type options} { error "Must supply an output filename for the compile to default_target_compile" } + set early_flags "" + # linker_opts_order is one of "sources-then-flags", "flags-then-sources". + # The order matters for things like -Wl,--as-needed. The default is to + # preserve existing behavior. + set linker_opts_order "sources-then-flags" set add_flags "" set libs "" set compiler_type "c" @@ -407,6 +412,10 @@ proc default_target_compile {source destfile type options} { regsub "^compiler=" $i "" tmp set compiler $tmp } + if {[regexp "^early_flags=" $i]} { + regsub "^early_flags=" $i "" tmp + append early_flags " $tmp" + } if {[regexp "^additional_flags=" $i]} { regsub "^additional_flags=" $i "" tmp append add_flags " $tmp" @@ -634,10 +643,26 @@ proc default_target_compile {source destfile type options} { # This is obscure: we put SOURCES at the end when building an # object, because otherwise, in some situations, libtool will # become confused about the name of the actual source file. - if {$type eq "object"} { - set opts "$add_flags $sources" - } else { - set opts "$sources $add_flags" + switch $type { + "object" { + set opts "$early_flags $add_flags $sources" + } + "executable" { + switch $linker_opts_order { + "flags-then-sources" { + set opts "$early_flags $add_flags $sources" + } + "sources-then-flags" { + set opts "$early_flags $sources $add_flags" + } + default { + error "Invalid value for board_info linker_opts_order" + } + } + } + default { + set opts "$early_flags $sources $add_flags" + } } if {[isremote host]} { |