Skip to content

Commit ededab6

Browse files
committed
Synchronize files with the official upstream source.
1 parent f672136 commit ededab6

File tree

3 files changed

+88
-59
lines changed

3 files changed

+88
-59
lines changed

.build/github/build_wrapper

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#! /usr/bin/env bash
2+
3+
panic()
4+
{
5+
echo "ERROR: $*"
6+
exit 1
7+
}
8+
9+
case "$CXX_COMPILER" in
10+
gcc)
11+
export CC="$GCC_CC_PATH"
12+
export CXX="$GCC_CXX_PATH"
13+
;;
14+
clang)
15+
export CC="$CLANG_CC_PATH"
16+
export CXX="$CLANG_CXX_PATH"
17+
;;
18+
*)
19+
panic "invalid compiler selection"
20+
;;
21+
esac
22+
23+
cat <<- EOF
24+
================================================================================
25+
CXX_COMPILER: $CXX_COMPILER
26+
CC: $CC
27+
CXX: $CXX
28+
================================================================================
29+
EOF
30+
exec "$@"

.github/workflows/docker_ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
image:
1818
- "ghcr.io/mdadams/clang_libs-ubuntu_24-llvm_20:latest"
1919
- "ghcr.io/mdadams/clang_libs-fedora_41-llvm_20:latest"
20+
compiler:
21+
- gcc
22+
- clang
2023
container:
2124
image: ${{matrix.image}}
2225
#credentials:
@@ -29,6 +32,9 @@ jobs:
2932
- uses: actions/checkout@v4.1.1
3033
- name: Build
3134
shell: bash
35+
env:
36+
CXX_COMPILER: ${{matrix.compiler}}
3237
run: |
3338
echo "image: ${{matrix.image}}"
34-
./build --defaults --num-jobs 0 --verbose-makefile --no-fmt --demo
39+
echo "compiler: ${{matrix.compiler}}"
40+
./.build/github/build_wrapper ./build --defaults --num-jobs 0 --verbose-makefile --no-fmt --demo

README.md

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
Companion Git Repository for "Lecture Slides for the Clang Libraries"
2-
=====================================================================
1+
# Companion Git Repository for "Lecture Slides for the Clang Libraries"
32

43
This repository contains all of the code examples that are associated
54
with the following slide deck:
65

76
- Michael D. Adams.
8-
Lecture Slides for the Clang Libraries [LLVM/Clang 20].
7+
*Lecture Slides for the Clang Libraries [LLVM/Clang 20]*.
98
Edition 0.3.0,
109
Mar. 2025.
1110

12-
Obtaining the Slide Deck
13-
------------------------
11+
## Obtaining the Slide Deck
1412

1513
The slide deck is available for download at:
1614

1715
- <https://www.ece.uvic.ca/~mdadams/cppbook/#clang_slides>
1816

19-
Organization of Repository
20-
--------------------------
17+
## Organization of Repository
2118

2219
The repository is organized as follows:
2320

24-
- slides/examples
21+
- `slides/examples`
2522
- This directory hierarchy contains all of the code examples from the
2623
slide deck.
2724
- Most of the code examples in this directory hierarchy have demo
2825
scripts that can be used to run the various example programs after
2926
they are built.
30-
- miscellany/examples
31-
- This directory hierarchy contains a few slightly longer code examples
27+
- `miscellany/examples`
28+
- This directory hierarchy contains a few longer code examples
3229
that are not shown on the slides in the slide deck.
3330

3431
Each code example or group of code examples is structured as a separate
@@ -39,19 +36,19 @@ For convenience, two CMakeLists.txt files are provided that build all of
3936
their subordinate projects. All of the projects can be built using a
4037
provided build script (which invokes these two CMake superbuilds).
4138

42-
GitHub CI Workflow
43-
------------------
39+
## GitHub CI Workflow
4440

4541
This repository employs a CI workflow based on GitHub Actions. Each time
4642
a new commit is pushed, the code examples in the repository are built
4743
and run as a basic sanity test. The workflow employs Podman/Docker
4844
container images based on Ubuntu and Fedora Linux. The Ubuntu container
49-
image was generated using the Ubuntu APT packages that are provided by
50-
the LLVM Project (at <https://apt.llvm.org/>). The code examples are
51-
built using both Clang and GCC.
45+
image is based on the Ubuntu APT packages provided by the LLVM Project
46+
(at <https://apt.llvm.org/>). The Fedora container image is based on
47+
the author's own build of LLVM (since LLVM 20 was not yet packaged
48+
in Fedora Linux at the time that the container image was generated).
49+
The code examples are built using both Clang and GCC.
5250

53-
Prerequisites to Building the Software
54-
--------------------------------------
51+
## Prerequisites to Building the Software
5552

5653
The code examples have the following software dependencies:
5754

@@ -69,27 +66,26 @@ These dependencies must be installed prior to building the code examples.
6966
If the C++ standard library does not support std::format, a custom version
7067
of the fmt library can be automatically installed (as part of the build
7168
process) to provide this support. (This custom version of the fmt library
72-
provides a standard library header called "format" and places a few key
73-
declarations in the std namespace in that header.) The C++ standard
69+
provides a standard library header called `format` and places a few key
70+
declarations in the `std` namespace in that header.) The C++ standard
7471
library included with version 13 and above of GCC has support for
75-
std::format.
72+
`std::format`.
7673

77-
For convenience, a Podman/Docker containerized environment is
78-
provided that includes all of the necessary software dependencies.
74+
**For convenience, a Podman/Docker containerized environment is
75+
provided that includes all of the necessary software dependencies.**
7976
More information on this containerized environment is provided in a
80-
later section.
77+
[later section](#PodmanDocker-Containerized-Demonstration-Environment).
8178

82-
Building the Software
83-
---------------------
79+
## Building the Software
8480

8581
The code examples employ a CMake-based build process. Each code example
8682
or group of related examples is structured as a separate CMake project.
8783
For convenience, a script is provided for building all of the code
8884
examples in one step.
8985

90-
Some of the code examples require std::format (introduced in C++20).
86+
Some of the code examples require `std::format` (introduced in C++20).
9187
If the C++ standard library implementation being used does not support
92-
std::format, a custom version of the fmt library can be automatically
88+
`std::format`, a custom version of the fmt library can be automatically
9389
installed (as part of the build process) to provide this support.
9490

9591
To build all of the code examples (and optionally run all of the associated
@@ -135,14 +131,14 @@ working tree of the cloned Git repository.
135131
./build --defaults
136132

137133
If the C++ standard library being used happens to support std::format, the
138-
"--no-fmt" option can be added to the invocation of the build script above
134+
`--no-fmt` option can be added to the invocation of the build script above
139135
(so that the custom version of the fmt library is not used). That is,
140136
the following command can be used:
141137

142138
./build --defaults --no-fmt
143139

144140
The build script supports numerous options. For detailed usage
145-
information, invoke the script with the "-h" or "--help" option.
141+
information, invoke the script with the `-h` or `--help` option.
146142
The command-line arguments are processed in left-to-right order.
147143
So, in the case where a setting is established by more than one
148144
command-line option, the setting from the rightmost option
@@ -155,23 +151,23 @@ command:
155151

156152
The output of the build process is placed in the directories:
157153

158-
- slides/examples/tmp_build
159-
- miscellany/examples/tmp_build
154+
- `slides/examples/tmp_build`
155+
- `miscellany/examples/tmp_build`
160156

161-
The output for each CMake project is placed in a directory having the same
162-
name as that project. For example, the build output for the project called
163-
cyclomatic_complexity from the slide-deck examples is placed in the directory:
157+
The output for each CMake project is placed in a directory having the
158+
same name as that project. For example, the build output for the project
159+
called `cyclomatic_complexity` from the slide-deck examples is placed
160+
in the directory:
164161

165162
slides/examples/tmp_build/cyclomatic_complexity
166163

167-
Most projects have a demo script (either called "demo" or with a name
168-
containing "demo"). For example, to run the demo script for the
169-
cyclomatic_complexity project, use the command:
164+
Most projects have a demo script (either called `demo` or with a name
165+
containing `demo`). For example, to run the demo script for the
166+
`cyclomatic_complexity` project, use the command:
170167

171168
slides/examples/tmp_build/cyclomatic_complexity/demo
172169

173-
Podman/Docker Containerized Demonstration Environment
174-
-----------------------------------------------------
170+
## Podman/Docker Containerized Demonstration Environment
175171

176172
A Dockerfile is provided that can be used to create a Podman/Docker
177173
container image with all of the necessary software dependencies for
@@ -188,9 +184,9 @@ Although these instructions use (rootless) Podman, the `podman` and `docker`
188184
programs have almost identical command-line interfaces. So, it should
189185
be possible to substitute `docker` for `podman` in the instructions.
190186

191-
Let $TOP_DIR denote the top-level directory of the working tree of the
187+
Let `$TOP_DIR` denote the top-level directory of the working tree of the
192188
cloned Git repository (i.e., the directory that contains the file named
193-
README.md which you are currently reading). Note that $TOP_DIR should
189+
`README.md` which you are currently reading). Note that `$TOP_DIR` should
194190
be an absolute path.
195191

196192
1. Set the working directory to the top-level directory of the working
@@ -225,32 +221,32 @@ be an absolute path.
225221
--cap-add=SYS_PTRACE --security-opt label=disable \
226222
clang_libs-fedora_41-llvm_20 /bin/bash
227223

228-
Note that the "--cap-add" and "--security-opt" options may not be
229-
needed.
224+
Note that the `--cap-add` and `--security-opt` options may not be
225+
needed. The `SYS_PTRACE` capability is typically needed in order
226+
to be able to run a debugger in the container (if desired).
230227

231228
If you do not want the container to be deleted after the Bash shell
232-
is exited, omit the "--rm" option.
229+
is exited, omit the `--rm` option.
233230

234231
4. Proceed to build and run the demo scripts as described in detail in
235232
an earlier section. For example, one might invoke the following
236233
command from the Bash shell running in the container:
237234

238235
./build --defaults
239236

240-
Remarks on the Use of Address Sanitizer (ASan)
241-
----------------------------------------------
237+
## Remarks on the Use of Address Sanitizer (ASan)
242238

243239
Sometimes the use of Address Sanitizer (ASan) can be problematic, due,
244240
for example, to quirks in the platform on which the code is being run.
245241
The runtime behavior of ASan can be controlled via the environment
246-
variable ASAN_OPTIONS, whose value is a colon-separated list of
247-
key-value pairs (e.g., "verbosity=1:detect_leaks=0").
242+
variable `ASAN_OPTIONS`, whose value is a colon-separated list of
243+
key-value pairs (e.g., `verbosity=1:detect_leaks=0`).
248244

249245
On some platforms, some of the libraries used by the code examples
250246
have been observed to have memory leaks. If ASan complains about some
251247
libraries having memory leaks, memory leak detection can be disabled
252-
by adding "detect_leaks=0" to the list of ASan options in the ASAN_OPTIONS
253-
environment variable. For example, ASAN_OPTIONS can be set as follows:
248+
by adding `detect_leaks=0` to the list of ASan options in the `ASAN_OPTIONS`
249+
environment variable. For example, `ASAN_OPTIONS` can be set as follows:
254250

255251
ASAN_OPTIONS=detect_leaks=0
256252

@@ -259,18 +255,15 @@ positives from ASan (namely, use-after-poison errors), depending on how
259255
LLVM/Clang was built. This is likely due to inconsistencies in how
260256
user poisoning is handled in the LLVM/Clang libraries and the application
261257
using these libraries. If this problem is encountered, user poisoning
262-
can be disabled by adding "allow_user_poisoning=0" to the list of ASan
263-
options in the ASAN_OPTIONS environment variable. For example,
264-
ASAN_OPTIONS can be set as follows:
258+
can be disabled by adding `allow_user_poisoning=0` to the list of ASan
259+
options in the `ASAN_OPTIONS` environment variable. For example,
260+
`ASAN_OPTIONS` can be set as follows:
265261

266262
ASAN_OPTIONS=allow_user_poisoning=0
267263

268-
Supported Platforms
269-
-------------------
264+
## Supported Platforms
270265

271266
This software should work with most Unix-based systems (provided that
272267
the necessary software dependencies are installed).
273268
The GitHub CI workflow (discussed above) ensures that the software should
274-
build and run reasonably reliably on Ubuntu Linux and macOS.
275-
The author's main development platform is Fedora Linux.
276-
So, the software should also work fairly reliably on this platform as well.
269+
build and run reasonably reliably on Ubuntu and Fedora Linux.

0 commit comments

Comments
 (0)