Compare commits

...

11 Commits

Author SHA1 Message Date
Riccardo
b99c2aebd5
Merge branch 'gulrak:master' into glibcxx_wchar_streams_workaround 2025-01-18 14:54:11 +01:00
Steffen Schümann
076592ce6e
Merge pull request #188 from bbannier/topic/bbannier/getcwd-with-NULL-buf
Avoid GNU `getcwd` extension behavior
2025-01-07 21:00:06 +01:00
Steffen Schümann
157feb3651
Merge pull request #190 from dpogue/wundef-fix
Check macros are defined before use
2025-01-05 17:01:49 +01:00
Darryl Pogue
f08e8b0064
Check macros are defined before use
This resolves warnings when compiling with -wundef (and errors when
combined with -werror).
2025-01-04 21:45:29 -08:00
Benjamin Bannier
99c3500205 Replace EOL centos CI with rockylinux
centos7 has reached EOL on 2024-06-30, centos8 on 2021-10-31. In
practical terms this means that their package repositories are offline
for the foreseeable future and the CI tasks making use of them might
never run again.

This patch replaces the existing CI jobs on centos7/centos8 with jobs on
rockylinux8/9. Since rockylinux is an open source variant similar to
RHEL this should provide testing with similar spirit. In contrast to
centos, rockylinux does provide very granular tagging of releases which
if used would help avoid breaking on e.g., subtle package changes in
their package repositories. I however did not use very precise tags in
the patch and instead went with broad "trains" for the 8 and 9 series;
I hope this minimizes maintenance overhead (e.g., bumping to new
releases) while still giving a good testing signal.
2024-12-18 15:45:33 +01:00
Benjamin Bannier
f43846877b Avoid GNU getcwd extension behavior
GNU `getcwd` can allocate a buffer if passed `NULL` for it. This is an
extension which is e.g., not recognized by clang-tidy-19's
`StdCLibraryFunctions` check[^1] which emits a diagnostic on a violated
precondition `buf != NULL`,

```
The 1st argument to 'getcwd' is NULL but should not be NULL [clang-analyzer-unix.StdCLibraryFunctions,-warnings-as-errors]
[build]  3987 |     std::unique_ptr<char, decltype(&std::free)> buffer{::getcwd(NULL, 0), std::free};
```

This patch modifies this use of `getcwd` with this extension behavior to
instead use `get_current_dir_name` which is also a GNU extension, but
does not trigger this diagnostic.

[^1]: https://clang.llvm.org/docs/analyzer/checkers.html#unix-stdclibraryfunctions-c
2024-12-18 15:26:19 +01:00
Steffen Schuemann
b1982f06c8 work on ci scripts 2024-04-27 12:20:18 +02:00
Steffen Schuemann
fbc5d213fc work on ci scripts 2024-04-27 12:07:57 +02:00
Steffen Schuemann
72a03b3c6d work on ci scripts 2024-04-27 12:00:20 +02:00
Steffen Schuemann
9fe68b91c7 work on ci scripts 2024-04-27 10:41:56 +02:00
Steffen Schuemann
56776c92f7 work on ci scripts 2024-04-27 09:58:19 +02:00
8 changed files with 86 additions and 100 deletions

View File

@ -1,6 +1,6 @@
freebsd_task: freebsd_task:
freebsd_instance: freebsd_instance:
image_family: freebsd-12-1 image_family: freebsd-14-0
install_script: | install_script: |
pkg install -y cmake pkg install -y cmake
pw groupadd testgrp pw groupadd testgrp
@ -11,25 +11,24 @@ freebsd_task:
test_script: | test_script: |
sudo -u testuser .ci/unix-test.sh sudo -u testuser .ci/unix-test.sh
centos7_task: rockylinux8_task:
container: container:
image: centos:7 image: docker.io/rockylinux:8
install_script: | install_script: |
yum install -y centos-release-scl dnf group install -y "Development Tools"
yum install -y devtoolset-9 dnf install cmake -y
curl -L https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.tar.gz | tar xzvf - -C /usr/local --strip-components 1
build_script: | build_script: |
source /opt/rh/devtoolset-9/enable && PATH=$PATH:/usr/local/bin .ci/unix-build.sh .ci/unix-build.sh
test_script: | test_script: |
PATH=$PATH:/usr/local/bin .ci/unix-test.sh .ci/unix-test.sh
centos8_task: rockylinux9_task:
container: container:
image: quay.io/centos/centos:stream8 image: docker.io/rockylinux:9
install_script: | install_script: |
yum group install -y "Development Tools" dnf group install -y "Development Tools"
curl -L https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.tar.gz | tar xzvf - -C /usr/local --strip-components 1 dnf install cmake -y
build_script: | build_script: |
PATH=$PATH:/usr/local/bin .ci/unix-build.sh .ci/unix-build.sh
test_script: | test_script: |
PATH=$PATH:/usr/local/bin .ci/unix-test.sh .ci/unix-test.sh

View File

@ -10,6 +10,42 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
config: config:
- name: "Ubuntu 22.04 GCC 11"
os: ubuntu-22.04
build_type: Release
packages: ninja-build
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17;cxx_std_20"
cc: gcc
cxx: g++
- name: "Ubuntu 22.04 Clang 13.0"
os: ubuntu-22.04
build_type: Release
packages: ninja-build libc++-13-dev libc++abi-13-dev
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17;cxx_std_20"
cc: clang-13
cxx: clang++-13
- name: "Ubuntu 22.04 Clang 15.0"
os: ubuntu-22.04
build_type: Release
packages: ninja-build libc++-15-dev libc++abi-15-dev
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17;cxx_std_20"
cc: clang-15
cxx: clang++-15
- name: "Ubuntu 22.04 GCC 11 coverage"
os: ubuntu-22.04
build_type: Debug
packages: ninja-build lcov
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17;cxx_std_20"
cc: gcc
cxx: g++
- name: "Ubuntu 20.04 GCC 9.3" - name: "Ubuntu 20.04 GCC 9.3"
os: ubuntu-20.04 os: ubuntu-20.04
build_type: Release build_type: Release
@ -46,69 +82,6 @@ jobs:
cc: gcc cc: gcc
cxx: g++ cxx: g++
- name: "Ubuntu 18.04 GCC 8.4"
os: ubuntu-18.04
build_type: Release
packages: ninja-build gcc-8 g++-8
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17"
cc: gcc-8
cxx: g++-8
- name: "Ubuntu 18.04 GCC 7.5"
os: ubuntu-18.04
build_type: Release
packages: ninja-build
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17"
cc: gcc-7
cxx: g++-7
- name: "Ubuntu 18.04 GCC 6.5"
os: ubuntu-18.04
build_type: Release
packages: ninja-build gcc-6 g++-6
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17"
cc: gcc-6
cxx: g++-6
- name: "Ubuntu 18.04 GCC 5.5"
os: ubuntu-18.04
build_type: Release
packages: ninja-build gcc-5 g++-5
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17"
cc: gcc-5
cxx: g++-5
- name: "Ubuntu 18.04 Clang 9.0"
os: ubuntu-18.04
build_type: Release
packages: ninja-build libc++-9-dev libc++abi-9-dev
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17;cxx_std_20"
cc: clang
cxx: clang++
- name: "Ubuntu 18.04 Clang 6.0"
os: ubuntu-18.04
build_type: Release
packages: ninja-build clang-6.0
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17"
cc: clang-6.0
cxx: clang++-6.0
- name: "Ubuntu 18.04 Clang 5.0"
os: ubuntu-18.04
build_type: Release
packages: ninja-build clang-5.0
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17"
cc: clang-5.0
cxx: clang++-5.0
- name: "Windows MSVC 2019" - name: "Windows MSVC 2019"
os: windows-2019 os: windows-2019
build_type: Release build_type: Release
@ -118,8 +91,17 @@ jobs:
cc: cl cc: cl
cxx: cl cxx: cl
- name: "macOS 10.15 AppleClang" - name: "macOS 13 AppleClang"
os: macos-10.15 os: macos-13
build_type: Release
packages: ninja
generator: Ninja
compatibility: "cxx_std_11;cxx_std_17;cxx_std_20"
cc: clang
cxx: clang++
- name: "macOS 12 AppleClang"
os: macos-12
build_type: Release build_type: Release
packages: ninja packages: ninja
generator: Ninja generator: Ninja
@ -127,7 +109,7 @@ jobs:
cc: clang cc: clang
cxx: clang++ cxx: clang++
- name: "macOS 11.6 AppleClang" - name: "macOS 11 AppleClang"
os: macos-11 os: macos-11
build_type: Release build_type: Release
packages: ninja packages: ninja

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7.2) cmake_minimum_required(VERSION 3.7.2)
project( project(
ghcfilesystem, ghcfilesystem,
VERSION 1.5.14 VERSION 1.5.15
) )
if (POLICY CMP0077) if (POLICY CMP0077)

View File

@ -4354,7 +4354,7 @@ GHC_INLINE path current_path(std::error_code& ec)
} }
return path(std::wstring(buffer.get()), path::native_format); return path(std::wstring(buffer.get()), path::native_format);
#elif defined(__GLIBC__) #elif defined(__GLIBC__)
std::unique_ptr<char, decltype(&std::free)> buffer { ::getcwd(NULL, 0), std::free }; std::unique_ptr<char, decltype(&std::free)> buffer { ::get_current_dir_name(), std::free };
if (buffer == nullptr) { if (buffer == nullptr) {
ec = detail::make_system_error(); ec = detail::make_system_error();
return path(); return path();

View File

@ -32,7 +32,7 @@
#ifndef GHC_FILESYSTEM_STD_H #ifndef GHC_FILESYSTEM_STD_H
#define GHC_FILESYSTEM_STD_H #define GHC_FILESYSTEM_STD_H
#if _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include) #if defined(_MSVC_LANG) && _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
// ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus // ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus
// _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/ // _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/
#if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html #if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html
@ -46,12 +46,12 @@
// Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS // Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS
// released after std::filesystem, where std::filesystem is always available. // released after std::filesystem, where std::filesystem is always available.
// (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.) // (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.)
#if __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \ #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \ || defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
|| __TV_OS_VERSION_MIN_REQUIRED && __TV_OS_VERSION_MIN_REQUIRED < 130000 \ || defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
|| __WATCH_OS_VERSION_MAX_ALLOWED && __WATCH_OS_VERSION_MAX_ALLOWED < 60000 || defined(__WATCH_OS_VERSION_MAX_ALLOWED) && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
#undef GHC_USE_STD_FS #undef GHC_USE_STD_FS
#endif #endif
#endif #endif
#endif #endif
#endif #endif

View File

@ -34,7 +34,7 @@
#ifndef GHC_FILESYSTEM_STD_FWD_H #ifndef GHC_FILESYSTEM_STD_FWD_H
#define GHC_FILESYSTEM_STD_FWD_H #define GHC_FILESYSTEM_STD_FWD_H
#if _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include) #if defined(_MSVC_LANG) && _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
// ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus // ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus
// _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/ // _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/
#if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html #if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html
@ -48,12 +48,12 @@
// Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS // Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS
// released after std::filesystem, where std::filesystem is always available. // released after std::filesystem, where std::filesystem is always available.
// (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.) // (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.)
#if __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \ #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \ || defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
|| __TV_OS_VERSION_MIN_REQUIRED && __TV_OS_VERSION_MIN_REQUIRED < 130000 \ || defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
|| __WATCH_OS_VERSION_MAX_ALLOWED && __WATCH_OS_VERSION_MAX_ALLOWED < 60000 || defined(__WATCH_OS_VERSION_MAX_ALLOWED) && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
#undef GHC_USE_STD_FS #undef GHC_USE_STD_FS
#endif #endif
#endif #endif
#endif #endif
#endif #endif

View File

@ -31,7 +31,7 @@
// The cpp has to include this before including fs_std_fwd.hpp directly or via a different // The cpp has to include this before including fs_std_fwd.hpp directly or via a different
// header to work. // header to work.
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
#if _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include) #if defined(_MSVC_LANG) && _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
// ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus // ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus
// _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/ // _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/
#if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html #if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html
@ -45,12 +45,12 @@
// Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS // Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS
// released after std::filesystem, where std::filesystem is always available. // released after std::filesystem, where std::filesystem is always available.
// (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.) // (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.)
#if __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \ #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \ || defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
|| __TV_OS_VERSION_MIN_REQUIRED && __TV_OS_VERSION_MIN_REQUIRED < 130000 \ || defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
|| __WATCH_OS_VERSION_MAX_ALLOWED && __WATCH_OS_VERSION_MAX_ALLOWED < 60000 || defined(__WATCH_OS_VERSION_MAX_ALLOWED) && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
#undef GHC_USE_STD_FS #undef GHC_USE_STD_FS
#endif #endif
#endif #endif
#endif #endif
#endif #endif

View File

@ -3,6 +3,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
set(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS ON) set(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS ON)
include(ParseAndAddCatchTests) include(ParseAndAddCatchTests)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND UNIX AND NOT APPLE AND NOT BSD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "-lc++abi")
endif()
function(SetTestCompileOptions target_name) function(SetTestCompileOptions target_name)
target_compile_options(${target_name} PRIVATE target_compile_options(${target_name} PRIVATE
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0> $<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>