()
| 193 | } |
| 194 | |
| 195 | func (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") |
nothing calls this directly
no test coverage detected