1- Companion Git Repository for "Lecture Slides for the Clang Libraries"
2- =====================================================================
1+ # Companion Git Repository for "Lecture Slides for the Clang Libraries"
32
43This repository contains all of the code examples that are associated
54with 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
1513The 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
2219The 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
3431Each 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
3936their subordinate projects. All of the projects can be built using a
4037provided build script (which invokes these two CMake superbuilds).
4138
42- GitHub CI Workflow
43- ------------------
39+ ## GitHub CI Workflow
4440
4541This repository employs a CI workflow based on GitHub Actions. Each time
4642a new commit is pushed, the code examples in the repository are built
4743and run as a basic sanity test. The workflow employs Podman/Docker
4844container 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
5653The code examples have the following software dependencies:
5754
@@ -69,27 +66,26 @@ These dependencies must be installed prior to building the code examples.
6966If the C++ standard library does not support std::format, a custom version
7067of the fmt library can be automatically installed (as part of the build
7168process) 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
7471library 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.**
7976More 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
8581The code examples employ a CMake-based build process. Each code example
8682or group of related examples is structured as a separate CMake project.
8783For convenience, a script is provided for building all of the code
8884examples 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).
9187If 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
9389installed (as part of the build process) to provide this support.
9490
9591To 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
156152The 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
176172A Dockerfile is provided that can be used to create a Podman/Docker
177173container image with all of the necessary software dependencies for
@@ -188,9 +184,9 @@ Although these instructions use (rootless) Podman, the `podman` and `docker`
188184programs have almost identical command-line interfaces. So, it should
189185be 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
192188cloned 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
194190be an absolute path.
195191
1961921 . 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
2342314 . 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
243239Sometimes the use of Address Sanitizer (ASan) can be problematic, due,
244240for example, to quirks in the platform on which the code is being run.
245241The 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
249245On some platforms, some of the libraries used by the code examples
250246have been observed to have memory leaks. If ASan complains about some
251247libraries 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
259255LLVM/Clang was built. This is likely due to inconsistencies in how
260256user poisoning is handled in the LLVM/Clang libraries and the application
261257using 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
271266This software should work with most Unix-based systems (provided that
272267the necessary software dependencies are installed).
273268The 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