|
1 | | -# S-CORE Bazel C/C++ Toolchain Configuration Repository |
2 | | - |
3 | | -This repository provides the configuration layer for all S-CORE C++ toolchains used in Bazel builds.</br> |
4 | | -It contains **no compiler binaries**. Instead, it defines: |
5 | | -* Toolchain configurations |
6 | | -* Toolchain rules and extensions for Bzlmod |
7 | | -* Common compiler flags |
8 | | -* Templates for generating toolchain configs |
9 | | -* Package descriptors for external toolchain binaries |
10 | | -* Tests ensuring correct toolchain behavior |
11 | | - |
12 | | -All toolchain binaries (GCC, QCC, etc.) are downloaded through Bazel repositories defined in consuming workspaces. </br> |
13 | | -This repository is structured and versioned as a Bazel module and is intended to be consumed through MODULE.bazel. |
14 | | - |
15 | | -## Key Goals |
16 | | - |
17 | | -* Provide a centralized, unified configuration source for all C++ toolchains used across S-CORE. |
18 | | -* Enforce consistency through shared flags, templates, and mandatory feature tests. |
19 | | -* Support multiple compilers (GCC, QCC) and multiple platforms (Linux, QNX). |
20 | | -* Ensure reproducible builds across architectures by separating: |
21 | | - * configuration logic (this repo). |
22 | | - * binary/toolchain distributions (external packages). |
23 | | -* Support plug-and-play toolchain activation via Bzlmod extensions. |
24 | | - |
25 | | -## Repository Structure |
26 | | - |
27 | | -```bash |
28 | | -. |
29 | | -│ |
30 | | -├── .github # Configuration directory for GitHub operations. |
31 | | -├── docs # Sphinx documentation sources. |
32 | | -├── examples # Functional examples for toolchain validation. |
33 | | -├── extensions # Module extensions for GCC/QCC toolchains |
34 | | -│ ├── BUILD |
35 | | -│ └── gcc.bzl # Module extension for setting up GCC toolchains in Bazel. |
36 | | -├── packages # Toolchain package descriptors (no binaries) |
37 | | -│ ├── linux/ # Linux toolchain versions (GCC only) |
38 | | -│ ├── qnx/ # QNX SDP/QCC toolchain metadata |
39 | | -│ └── version_matrix.bzl # Supported toolchain version definitions |
40 | | -├── rules # Bazel rule implementations for toolchains |
41 | | -│ ├── BUILD |
42 | | -│ ├── common.bz # Common rules used by all drivers |
43 | | -│ └── gcc.bzl # Module rule for defining GCC toolchains in Bazel. |
44 | | -├── templates # Templates for toolchain definition and configuration |
45 | | -│ ├── linux/ |
46 | | -│ ├── qnx/ |
47 | | -│ ├── BUILD |
48 | | -│ └── BUILD.template |
49 | | -├── tools # Utility scripts (e.g., QNX credential helper) |
50 | | -├── MODULE.bazel # Module declaration for Bzlmod |
51 | | -├── BUILD |
52 | | -├── LICENSE |
53 | | -├── NOTICE |
54 | | -└── README.md |
55 | | -``` |
56 | | - |
57 | | -## Toolchain Model |
58 | | - |
59 | | -This repository does not contain compiler binaries. </br> |
60 | | -Instead: |
61 | | -- Toolchain **packages** describe how to fetch compiler binaries via `http_archive` or internal artifact storage. |
62 | | -- Toolchain **templates** describe how Bazel should use the binaries. |
63 | | -- Toolchain **rules** and **extensions** generate and register toolchains. |
64 | | -- Toolchain **examples** validate the toolchains. |
65 | | -- This separation provides: |
66 | | - - Hermetic configurations |
67 | | - - Full reproducibility |
68 | | - - Clear ownership boundaries |
69 | | - - Easy addition of new compilers or versions |
70 | | - |
71 | | - |
72 | | -## Using Toolchains in a different Bazel Module |
73 | | - |
74 | | -### GCC Example (Linux x86_64) |
75 | | - |
76 | | -```starlark |
77 | | -bazel_dep(name = "score_cpp_toolchains", version = "0.1.0") |
78 | | -use_extension("@score_cpp_toolchains//extensions:gcc.bzl", "gcc") |
79 | | -gcc( |
80 | | - target_os = "linux", |
81 | | - target_cpu = "x86_64", |
82 | | - version = "12.2.0", |
83 | | - use_default_package = True, |
84 | | -) |
85 | | -use_repo(gcc, "score_gcc_toolchain") |
86 | | -``` |
87 | | - |
88 | | -### QCC Example (QNX ARM64) |
89 | | - |
90 | | -```starlark |
91 | | -bazel_dep(name = "score_cpp_toolchains", version = "0.2.0") |
92 | | -use_extension("@score_cpp_toolchains//extensions:gcc.bzl", "gcc") |
93 | | -gcc( |
94 | | - target_os = "qnx", |
95 | | - target_cpu = "arm64", |
96 | | - sdp_version = "8.0.0", |
97 | | - version = "12.2.0", |
98 | | - use_default_package = True, |
99 | | -) |
100 | | -use_repo(gcc, "score_gcc_qnx_toolchain") |
101 | | -``` |
102 | | - |
103 | | -The registration of toolchains is done by adding command line option `--extra_toolchains=@<toolchain_repo>//:toolchain_name` |
104 | | -In case above this would be: |
105 | | -```bash |
106 | | ---extra_toolchains=@score_gcc_toolchain//:x86_64-linux-gcc-12.2.0 |
107 | | ---extra_toolchains=@score_gcc_qnx_toolchain//:x86_64-qnx-sdp-8.0.0 |
108 | | -``` |
109 | | - |
110 | | -> NOTE: In case that more than one toolchain needs to be defined, the registration must be protected via config flags otherwise</br> |
111 | | -the first toolchain that matches constraints will be selected by toolchain resolutions. |
112 | | - |
113 | | -## Configuration Flags |
114 | | - |
115 | | -Shared flag sets live under: |
116 | | - |
117 | | -- [linux](templates/linux/cc_toolchain_flags.bzl.template) |
118 | | -- [qnx](templates/qnx/cc_toolchain_config.bzl.template) |
119 | | - |
120 | | -These define: |
121 | | - |
122 | | -- Base C/C++ flags |
123 | | -- Optimization flags |
124 | | -- PIC/PIE handling |
125 | | -- Debug and sanitizer modes |
126 | | -- Linker behavior |
127 | | -- Warning levels |
128 | | - |
129 | | -## Templates |
130 | | - |
131 | | -Templates define how toolchain files are generated: |
132 | | - |
133 | | -- `BUILD.template` |
134 | | -- `cc_toolchain_config.bzl.template` |
135 | | -- `cc_gcov_wrapper.template` |
136 | | -- `cc_toolchain_flags.bzl.template` |
137 | | - |
138 | | -These templates simplify adding: |
| 1 | +<!-- |
| 2 | +# ******************************************************************************* |
| 3 | +# Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 4 | +# |
| 5 | +# See the NOTICE file(s) distributed with this work for additional |
| 6 | +# information regarding copyright ownership. |
| 7 | +# |
| 8 | +# This program and the accompanying materials are made available under the |
| 9 | +# terms of the Apache License Version 2.0 which is available at |
| 10 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# SPDX-License-Identifier: Apache-2.0 |
| 13 | +# ******************************************************************************* |
| 14 | +--> |
139 | 15 |
|
140 | | -- New compiler versions |
141 | | -- New compiler families |
142 | | -- New OS/arch combinations |
143 | | - |
144 | | -## Testing and Validation |
145 | | - |
146 | | -Testing is part of the **integration gate pipeline**. |
147 | | - |
148 | | -## Examples |
149 | | - |
150 | | -Example cover: |
151 | | - |
152 | | -- Simple compilation ( [examples/main.cpp](./examples/main.cpp)) |
153 | | -- Toolchain registration behavior ([examples/.bazelrc](./examples/.bazelrc)) |
154 | | - |
155 | | -# Documentation |
156 | | - |
157 | | -Documentation uses **Sphinx** and lives in `docs/`. (Not yet prepared!) |
158 | | - |
159 | | -# QNX License |
160 | | - |
161 | | -## Local License File |
162 | | - |
163 | | -By default, the QNX toolchain uses `/opt/score_qnx/license/licenses` as the license path. |
164 | | -If you want to change this location, you can override it by setting the `license_path` variable |
165 | | -when calling the `gcc.toolchain(...)` function in your `MODULE.bazel` file. |
166 | | - |
167 | | -**Example:** |
168 | | - |
169 | | -```bazel |
170 | | -gcc.toolchain( |
171 | | - name = "score_qcc_toolchain", |
172 | | - target_os = "qnx", |
173 | | - ... |
174 | | - license_path = "/path/to/your/custom/licenses", |
175 | | -) |
176 | | -``` |
177 | | - |
178 | | -> **TODO:** Is it possible to set this via environment variable? |
179 | | -
|
180 | | -## License Servers |
181 | | - |
182 | | -In case you are using a license server for QNX licenses (FLEXlm), you can set the license server information |
183 | | -either locally in your module or centrally in your bazel configuration. |
184 | | -This also applies to floating licenses. |
185 | | - |
186 | | -### Module Local Configuration |
187 | | - |
188 | | -You can set the license server for your toolchains by setting the variables `license_info_variable` and |
189 | | -`license_info_url` when calling the `gcc.toolchain(...)` function in your `MODULE.bazel` file. |
190 | | - |
191 | | -**Example (for QNXLM_LICENSE_FILE variable):** |
192 | | - |
193 | | -```bazel |
194 | | -gcc.toolchain( |
195 | | - name = "score_qcc_toolchain", |
196 | | - target_os = "qnx", |
197 | | - ... |
198 | | - license_info_variable = "QNXLM_LICENSE_FILE", |
199 | | - license_info_url = "<port>@<license_server_host>", |
200 | | -) |
201 | | -``` |
202 | | - |
203 | | -### Central Configuration |
204 | | - |
205 | | -In case you want to set the license server for all your bazel projects you can set the |
206 | | -environment variable in your `~/.bazelrc` file: |
207 | | - |
208 | | -**Example (for QNXLM_LICENSE_FILE variable):** |
209 | | - |
210 | | -```bazel |
211 | | -common --action_env=QNXLM_LICENSE_FILE=<port>@<license_server_host> |
212 | | -``` |
213 | | - |
214 | | -In case you do not want to set it for all commands you can also set it per build/test command: |
215 | | - |
216 | | -```bazel |
217 | | -build --action_env=QNXLM_LICENSE_FILE=<port>@<license_server_host> |
218 | | -test --action_env=QNXLM_LICENSE_FILE=<port>@<license_server_host> |
219 | | -``` |
| 16 | +# S-CORE Bazel C/C++ Toolchain Configuration Repository |
220 | 17 |
|
221 | | -# Adding New Toolchain Versions |
| 18 | +This repository contains the configuration layer for S-CORE C and C++ |
| 19 | +toolchains used in Bazel builds. It does not ship compiler binaries. Instead, |
| 20 | +it defines the metadata, templates, repository rules, module extension logic, |
| 21 | +and validation workspace needed to fetch and register external toolchain |
| 22 | +packages reproducibly. |
222 | 23 |
|
223 | | -1. Update `packages/version_matrix.bzl` |
224 | | -2. Add a package descriptor (e.g., `packages/linux/x86_64/gcc/13.1.0`) |
225 | | -3. Generate configuration from templates |
226 | | -4. Update flags if needed |
227 | | -5. Submit through integration gate |
| 24 | +The documentation below is organized around the main subsystems of the |
| 25 | +repository: how consumers declare toolchains, how Bazel repositories are |
| 26 | +generated, how platform packages are described, how the example workspace |
| 27 | +validates the setup, and how QNX-specific authentication and licensing fit in. |
228 | 28 |
|
229 | | ---- |
| 29 | +## Documentation |
230 | 30 |
|
231 | | -# Tools |
| 31 | +- [Overview](docs/overview.md) |
| 32 | +- [Repository layout](docs/repository_layout.md) |
| 33 | +- [Extension API](docs/extension_api.md) |
| 34 | +- [Generation flow](docs/generation_flow.md) |
| 35 | +- [Examples and validation](docs/examples_and_validation.md) |
| 36 | +- [QNX integration](docs/qnx_integration.md) |
| 37 | +- [Maintenance](docs/maintenance.md) |
232 | 38 |
|
233 | | -Utility scripts such as: |
| 39 | +## Quick Summary |
234 | 40 |
|
235 | | -``` |
236 | | -tools/qnx_credential_helper.py |
237 | | -``` |
| 41 | +**Library:** S-CORE Bazel C/C++ toolchain configurations |
238 | 42 |
|
239 | | -are used for repository authentication flows. |
| 43 | +**Type:** Bazel module with repository rules, templates, and example validation |
240 | 44 |
|
241 | | ---- |
| 45 | +**Primary consumer entry point:** `@score_bazel_cpp_toolchains//extensions:gcc.bzl` |
242 | 46 |
|
243 | | -# License |
| 47 | +**Main validation surface:** `examples/` smoke-test workspace |
244 | 48 |
|
245 | | -Distributed under: |
| 49 | +## Key Capabilities |
246 | 50 |
|
247 | | -- `LICENSE` |
248 | | -- `NOTICE` |
| 51 | +- Define Linux and QNX toolchains through a Bzlmod extension. |
| 52 | +- Resolve default package metadata through `packages/version_matrix.bzl`. |
| 53 | +- Generate toolchain repositories from platform-specific templates. |
| 54 | +- Support both packaged and locally built QNX SDP flows. |
| 55 | +- Validate toolchain selections through the example workspace test matrix. |
0 commit comments