MCPcopy Create free account
hub / github.com/celer-pkg/celer / buildOptions

Method buildOptions

buildsystems/build_b2.go:195–310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

193}
194
195func (b b2) buildOptions() ([]string, error) {
196 var options = slices.Clone(b.Options)
197 toolchain := b.Ctx.Platform().GetToolchain()
198 toolchainName := toolchain.GetName()
199
200 // Set build toolset with version for cross-compilation.
201 var toolsetName string
202 switch toolchainName {
203 case "msvc":
204 toolsetName = "msvc-" + b.msvcVersion()
205 case "clang-cl":
206 toolsetName = "clang-win"
207 case "gcc":
208 toolsetName = "gcc"
209 case "clang":
210 toolsetName = "clang"
211 case "qcc":
212 toolsetName = "qcc"
213 default:
214 return nil, fmt.Errorf("unsupported toolchain: %s for b2", toolchain.GetName())
215 }
216 rootfs := b.Ctx.RootFS()
217 if !b.DevDep && rootfs != nil {
218 options = append(options, "toolset="+toolsetName+"-"+toolchain.GetVersion())
219 } else {
220 options = append(options, "toolset="+toolsetName)
221 }
222
223 // Set target-os and architecture for QNX.
224 isQNX := toolchainName == "qcc"
225 if isQNX {
226 options = append(options, "target-os=qnxnto")
227 }
228
229 // Set compiler and linker flags for cross-compilation.
230 if !b.DevDep && rootfs != nil {
231 sysroot := rootfs.GetAbsDir()
232 if sysroot != "" && !strings.Contains(toolchain.GetName(), "clang") && !isQNX {
233 options = append(options, fmt.Sprintf(`cflags="--sysroot=%s"`, sysroot))
234 options = append(options, fmt.Sprintf(`cxxflags="--sysroot=%s"`, sysroot))
235 options = append(options, fmt.Sprintf(`linkflags="--sysroot=%s"`, sysroot))
236 }
237 }
238
239 // Boost build system (b2) requires architecture and ABI specifications.
240 //
241 // ABI (Application Binary Interface) Selection Strategy:
242 // - x86/x86_64: Boost Jamfile has default rules for SYSV ABI (Linux) and MS ABI (Windows).
243 // No explicit ABI needed; b2 will auto-select based on platform.
244 // - ARM32/ARM64: Boost Jamfile ONLY has AAPCS ABI rules, NO SYSV rules exist.
245 // Without explicit "abi=aapcs", b2 defaults to SYSV which has no ARM rules,
246 // causing build failure: "No best alternative for asm_sources".
247 // Solution: Always specify "abi=aapcs" for ARM architectures.
248 switch toolchain.GetSystemProcessor() {
249 case "x86_64", "amd64":
250 options = append(options, "address-model=64", "architecture=x86")
251 case "x86":
252 options = append(options, "address-model=32", "architecture=x86")

Callers

nothing calls this directly

Calls 12

msvcVersionMethod · 0.95
SprintfMethod · 0.80
buildLibraryTypeMethod · 0.80
expandVariablesMethod · 0.80
CloneMethod · 0.65
GetToolchainMethod · 0.65
PlatformMethod · 0.65
GetNameMethod · 0.65
RootFSMethod · 0.65
GetVersionMethod · 0.65
GetAbsDirMethod · 0.65
GetSystemProcessorMethod · 0.65

Tested by

no test coverage detected