Skip to content

Commit e098ab8

Browse files
committed
ci: enable macos
fix cppalliance#558 fix cppalliance#694
1 parent 9348766 commit e098ab8

File tree

6 files changed

+63
-23
lines changed

6 files changed

+63
-23
lines changed

.github/workflows/ci.yml

+27-18
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,26 @@ jobs:
3737
gcc 14
3838
clang 18
3939
msvc >=14.40
40+
apple-clang *
4041
standards: '20'
4142
latest-factors: ''
4243
factors: |
4344
msvc Optimized-Debug
45+
runs-on: |
46+
apple-clang: macos-15
4447
build-types: |
4548
gcc: Release
4649
clang: Release
50+
apple-clang: Release
4751
msvc: RelWithDebInfo
4852
msvc Optimized-Debug: Debug
4953
ccflags: |
5054
msvc Optimized-Debug: /Ob1 /O2 /Zi
5155
cxxflags: |
5256
msvc Optimized-Debug: /Ob1 /O2 /Zi
5357
install: |
54-
gcc: git build-essential pkg-config python3 curl openjdk-11-jdk ninja-build pkg-config libncurses-dev libxml2-utils libxml2-dev
55-
clang: git build-essential pkg-config python3 curl openjdk-11-jdk ninja-build pkg-config libncurses-dev libxml2-utils libxml2-dev
58+
gcc: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev
59+
clang: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev
5660
msvc: ''
5761
extra-values: |
5862
llvm-hash: e1065370aaacb1b1cb48e77d37d376bf024f4a39
@@ -68,6 +72,8 @@ jobs:
6872
llvm-archive-filename: {{ llvm-archive-basename }}.{{ llvm-archive-extension }}
6973
libcxx-runtimes: libcxx;libcxxabi{{#if (ine os 'windows') }};libunwind{{/if}}
7074
libcxx-targets: cxx {{#if (ine os 'windows') }}cxxabi unwind{{/if}} install-cxx {{#if (ine os 'windows') }}install-cxxabi install-unwind{{/if}}
75+
libcxx-cxxflags: {{#if (ieq os 'windows') }}-D__ORDER_LITTLE_ENDIAN__=1234 -D__ORDER_BIG_ENDIAN__=4321 -D__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__{{/if}}
76+
libcxx-cmake-args: -D LLVM_ENABLE_RUNTIMES="{{ libcxx-runtimes }}" {{#if (ieq os 'windows') }}-D LIBCXXABI_USE_LLVM_UNWINDER=OFF -D LIBCXXABI_ENABLE_SHARED=OFF -D LIBCXXABI_ENABLE_STATIC=ON -D LIBCXX_ENABLE_SHARED=OFF -D LIBCXX_NO_VCRUNTIME=ON{{/if}} {{#if (ieq os 'macos') }}-D CMAKE_OSX_ARCHITECTURES=""{{/if}}
7177
mrdocs-ccflags: {{ ccflags }} {{#if (eq compiler 'gcc') }}-static{{/if}} {{#if asan }}-static-libasan{{/if}} {{#if tsan }}-static-libtsan{{/if}}
7278
mrdocs-cxxflags: {{ cxxflags }} {{#if (eq compiler 'gcc') }}-static{{/if}} {{#if asan }}-static-libasan{{/if}} {{#if tsan }}-static-libtsan{{/if}}
7379
mrdocs-package-generators: {{#if (ieq os 'windows') }}7Z ZIP WIX{{else}}TGZ TXZ{{/if}}
@@ -131,8 +137,7 @@ jobs:
131137
trace-commands: 'true'
132138

133139
- name: Setup Ninja
134-
uses: seanmiddleditch/gha-setup-ninja@v4
135-
if: ${{ runner.os == 'Windows' }}
140+
uses: seanmiddleditch/gha-setup-ninja@v5
136141

137142
- name: Setup C++
138143
uses: alandefreitas/cpp-actions/[email protected]
@@ -141,6 +146,15 @@ jobs:
141146
compiler: ${{ matrix.compiler }}
142147
version: ${{ matrix.version }}
143148

149+
# If apple-clang on macos, we run `clang -print-targets` to
150+
# get the list of targets supported by the compiler.
151+
- name: Print Clang Targets
152+
if: matrix.compiler == 'apple-clang'
153+
run: |
154+
set -x
155+
${{ steps.setup-cpp.outputs.cxx }} --print-targets
156+
${{ steps.setup-cpp.outputs.cxx }} --print-target-triple
157+
144158
- name: Install System Packages
145159
uses: alandefreitas/cpp-actions/[email protected]
146160
if: matrix.compiler != 'msvc'
@@ -323,24 +337,19 @@ jobs:
323337
source-dir: ../third-party/llvm-project/runtimes
324338
build-dir: ${sourceDir}/build-libcxx
325339
build-target: ${{ matrix.libcxx-targets }}
326-
cc: ../third-party/llvm-project/install/bin/clang
327-
cxx: ../third-party/llvm-project/install/bin/clang++
328-
cxxflags: ${{ runner.os == 'Windows' && '-D__ORDER_LITTLE_ENDIAN__=1234 -D__ORDER_BIG_ENDIAN__=4321 -D__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__' || '' }}
340+
# MrDocs will only use the LibC++ headers: any compiler that works in this workflow will do
341+
cc: ${{ runner.os == 'macOS' && steps.setup-cpp.outputs.cc || '../third-party/llvm-project/install/bin/clang' }}
342+
cxx: ${{ runner.os == 'macOS' && steps.setup-cpp.outputs.cxx || '../third-party/llvm-project/install/bin/clang++' }}
343+
cxxflags: ${{ matrix.libcxx-cxxflags }}
329344
generator: Ninja
330-
extra-args: |
331-
-D LLVM_ENABLE_RUNTIMES="${{ matrix.libcxx-runtimes }}"
332-
${{ runner.os == 'Windows' && '-D LIBCXXABI_USE_LLVM_UNWINDER=OFF' || '' }}
333-
${{ runner.os == 'Windows' && '-D LIBCXXABI_ENABLE_SHARED=OFF' || '' }}
334-
${{ runner.os == 'Windows' && '-D LIBCXXABI_ENABLE_STATIC=ON' || '' }}
335-
${{ runner.os == 'Windows' && '-D LIBCXX_ENABLE_SHARED=OFF' || '' }}
336-
${{ runner.os == 'Windows' && '-D LIBCXX_NO_VCRUNTIME=ON' || '' }}
345+
extra-args: ${{ matrix.libcxx-cmake-args }}
337346
install: true
338347
install-prefix: ${sourceDir}/../install
339348
run-tests: false
340349
trace-commands: true
341350

342351
- name: Install Node.js
343-
uses: actions/setup-node@v3
352+
uses: actions/setup-node@v4
344353
with:
345354
node-version: '20'
346355

@@ -427,12 +436,12 @@ jobs:
427436
uses: actions/checkout@v4
428437

429438
- name: Install Node.js
430-
uses: actions/setup-node@v3
439+
uses: actions/setup-node@v4
431440
with:
432441
node-version: '18'
433442

434443
- name: Setup Ninja
435-
uses: seanmiddleditch/gha-setup-ninja@v4
444+
uses: seanmiddleditch/gha-setup-ninja@v5
436445
if: ${{ runner.os == 'Windows' }}
437446

438447
- name: Download MrDocs package
@@ -445,7 +454,7 @@ jobs:
445454
run: |
446455
set -x
447456
if [[ ${{ runner.os }} != 'Windows' ]]; then
448-
dest_dir="/usr/local"
457+
dest_dir="$HOME/local"
449458
find packages -maxdepth 1 -name 'MrDocs-*.tar.gz' -exec tar -vxzf {} -C $dest_dir --strip-components=1 \;
450459
else
451460
dest_dir="$GITHUB_WORKSPACE/usr/local"

docs/modules/ROOT/pages/install.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ export CXX="./install/bin/clang++"
407407
export CC="./install/bin/clang"
408408
----
409409

410+
These options set the C and pass:[C++] compilers to the ones previously installed by LLVM.
411+
MrDocs only depends on the pass:[LibC++] headers, so any compiler that works for this step should be fine.
412+
410413
Run a command such as the following to configure LLVM:
411414

412415
[tabs]

include/mrdocs/Platform.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ namespace mrdocs {
7272
# endif
7373
#endif
7474

75-
#if ! defined(__x86_64__) && ! defined(_WIN64)
76-
# error mrdox requires a 64-bit archtecture
75+
#if ! defined(__x86_64__) && ! defined(_WIN64) && ! defined(__aarch64__)
76+
# error mrdocs requires a 64-bit architecture
7777
#endif
7878

7979
} // mrdocs

src/lib/Lib/CMakeExecution.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ parseBashArgs(std::string_view str)
383383
return args;
384384
}
385385

386+
/* Pushes the CMake arguments to the `args` vector, replacing the
387+
* default generator with Ninja if Visual Studio is the default generator.
388+
*/
386389
Expected<void>
387390
pushCMakeArgs(
388391
std::string const& cmakePath,

src/lib/Lib/MrDocsCompilationDatabase.cpp

+27-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <llvm/Option/ArgList.h>
2222
#include <llvm/Option/OptTable.h>
2323
#include <llvm/Support/FileSystem.h>
24+
#include <llvm/TargetParser/Host.h>
2425
#include <ranges>
2526

2627
namespace clang {
@@ -243,8 +244,8 @@ static
243244
std::vector<std::string>
244245
adjustCommandLine(
245246
llvm::StringRef workingDir,
246-
const std::vector<std::string>& cmdline,
247-
const std::vector<std::string>& additional_defines,
247+
std::vector<std::string> const& cmdline,
248+
std::vector<std::string> const& additional_defines,
248249
std::unordered_map<std::string, std::vector<std::string>> const& implicitIncludeDirectories,
249250
std::vector<std::string> const& stdlibIncludes,
250251
std::vector<std::string> const& systemIncludes,
@@ -292,6 +293,30 @@ adjustCommandLine(
292293
new_cmdline.emplace_back(is_clang_cl ? "/w" : "-w");
293294
new_cmdline.emplace_back("-fsyntax-only");
294295

296+
// ------------------------------------------------------
297+
// Target architecture
298+
// ------------------------------------------------------
299+
constexpr auto is_target_option = [](std::string_view opt) {
300+
return opt == "-target" || opt == "--target";
301+
};
302+
if (std::ranges::find_if(cmdline, is_target_option) == cmdline.end())
303+
{
304+
new_cmdline.emplace_back("-target");
305+
std::string target = llvm::sys::getDefaultTargetTriple();
306+
new_cmdline.emplace_back(target);
307+
}
308+
309+
// ------------------------------------------------------
310+
// Language standard
311+
// ------------------------------------------------------
312+
constexpr auto is_std_option = [](std::string_view opt) {
313+
return opt.starts_with("-std=") || opt.starts_with("--std=") || opt.starts_with("/std:");
314+
};
315+
if (std::ranges::find_if(cmdline, is_std_option) == cmdline.end())
316+
{
317+
new_cmdline.emplace_back("-std=c++23");
318+
}
319+
295320
// ------------------------------------------------------
296321
// Add additional defines
297322
// ------------------------------------------------------

src/lib/Support/Error.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ call_impl(
258258
e->location().line());
259259
}
260260
os << fmt::format(
261-
" Reported From: `{}` at line {}",
261+
" Reported From: `{}` at line {}\n",
262262
::SourceFileNames::getFileName(loc->file_name()),
263263
loc->line());
264264
// VFALCO attach a stack trace for Level::fatal

0 commit comments

Comments
 (0)