Skip to content

Commit 1adb209

Browse files
allow explicit target triple for clang-linux and clang-darwin (#466)
Co-authored-by: René Ferdinand Rivera Morell <grafikrobot@gmail.com>
1 parent 96e9206 commit 1adb209

3 files changed

Lines changed: 34 additions & 10 deletions

File tree

src/tools/clang-darwin.jam

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ rule init ( version ? : command * : options * )
5050
: version $(version) ] ;
5151

5252
common.handle-options clang-darwin : $(condition) : $(command) : $(options) ;
53-
clang.init-flags clang-darwin : $(condition) : $(version) ;
53+
clang.init-flags clang-darwin : $(condition) : $(version) :
54+
[ feature.get-values <triplet> : $(options) ] ;
5455

5556
# - Archive builder.
5657
local archiver = [ feature.get-values <archiver> : $(options) ] ;

src/tools/clang-linux.jam

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
= Clang (GCC frontend)
1414

1515
The `clang-linux` module supports Clang with GCC frontend and has the same
16-
options as link:#b2.reference.tools.compiler.gcc[`gcc`] toolset.
16+
options as link:#b2.reference.tools.compiler.gcc[`gcc`] toolset, with the
17+
addition of `<triple>` option.
18+
19+
The value of that option is passed as the value of `--target=` flag, unless
20+
provided as `<triple>none`. In that case the flag is not passed to the build
21+
tools. If the option is not provided the build system may try to guess the
22+
correct target triple.
1723

1824
|# # end::doc[]
1925

@@ -68,7 +74,8 @@ rule init ( version ? : command * : options * ) {
6874
: version $(version) ] ;
6975

7076
common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
71-
clang.init-flags clang-linux : $(condition) : $(version) ;
77+
clang.init-flags clang-linux : $(condition) : $(version) :
78+
[ feature.get-values <triple> : $(options) ] ;
7279

7380
# Support for gcc root as the backend, this is mainly useful for clang/gcc on Windows
7481
# since on Linux gcc will be the default compiler already located on the PATH.

src/tools/clang.jam

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,36 @@ local rule init-flags-cross ( toolset : condition * : architecture + : address-m
9292
case x86-32 : arch = i386 ;
9393
}
9494

95-
toolset.flags $(toolset)
96-
OPTIONS $(condition)/<target-os>$(target-os)/<architecture>$(_architecture_)/<address-model>$(_address-model_)
97-
: "--target=$(arch)-$(vendor-sys)"
98-
: unchecked ;
95+
set-triple $(toolset) :
96+
$(condition)/<target-os>$(target-os)/<architecture>$(_architecture_)/<address-model>$(_address-model_)
97+
: "$(arch)-$(vendor-sys)"
98+
;
9999
}
100100
}
101101
}
102102

103-
rule init-flags ( toolset : condition * : version )
103+
local rule set-triple ( toolset : condition : triple )
104+
{
105+
toolset.flags $(toolset) OPTIONS $(condition) : --target=$(triple)
106+
: unchecked ;
107+
}
108+
109+
rule init-flags ( toolset : condition * : version : triple ? )
104110
{
105111
init-cxxstd-flags $(toolset) : $(condition) : $(version) ;
106112

107-
init-flags-cross $(toolset) : $(condition) : arm x86 : 64 : darwin ;
108-
init-flags-cross $(toolset) : $(condition) : arm x86 : 64 32 : linux ;
113+
if ! $(triple)
114+
{
115+
init-flags-cross $(toolset) : $(condition) : arm x86 : 64 : darwin ;
116+
init-flags-cross $(toolset) : $(condition) : arm x86 : 64 32 : linux ;
117+
}
118+
else
119+
{
120+
if $(triple) != none
121+
{
122+
set-triple $(toolset) : $(condition) : $(triple) ;
123+
}
124+
}
109125

110126
# This is a temporary solution for doing combined architecture builds on macOS.
111127
toolset.flags $(toolset)

0 commit comments

Comments
 (0)