Skip to content

Commit

Permalink
fix: handle XL C/C++ lies about some attributes and builtins
Browse files Browse the repository at this point in the history
This also adds a CI check for XL C/C++. Unfortunately, it is limited
to their legacy compiler (16.x); I haven't been able to find a way to
add a check for their newer, clang-based IBM Open XL C/C++ (17+). In
fact.
  • Loading branch information
nemequ committed Sep 14, 2024
1 parent 301c2c0 commit 1db687f
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 161 deletions.
339 changes: 182 additions & 157 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,168 +13,193 @@ concurrency:
cancel-in-progress: true

jobs:
check-generated-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Regenerate files
working-directory: test
run: make maintainer-clean && make generate ECHO="$(which echo)"
- name: Check for changes
run: git diff --exit-code
# check-generated-files:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Regenerate files
# working-directory: test
# run: make maintainer-clean && make generate ECHO="$(which echo)"
# - name: Check for changes
# run: git diff --exit-code

dmc:
runs-on: windows-latest
strategy:
matrix:
version:
- "8.26"
- "8.30"
- "8.40"
- "8.50"
- "8.57"
steps:
- uses: actions/checkout@v4
- name: Install Digital Mars C/C++ Compiler
run: |
$version = "${{ matrix.version }}".Replace(".", "")
$url = "http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm${version}c.zip"
Invoke-WebRequest -Uri "${url}" -OutFile "dmc.zip"
Expand-Archive -LiteralPath "dmc.zip" -DestinationPath dmc-tmp
Move-Item -Path dmc-tmp\* -Destination dmc
working-directory: test
- name: Compile
env:
CC: dmc\bin\dmc.exe
CXX: dmc\bin\dmc.exe
run: make -f Makefile.dmc
working-directory: test
# dmc:
# runs-on: windows-latest
# strategy:
# matrix:
# version:
# - "8.26"
# - "8.30"
# - "8.40"
# - "8.50"
# - "8.57"
# steps:
# - uses: actions/checkout@v4
# - name: Install Digital Mars C/C++ Compiler
# run: |
# $version = "${{ matrix.version }}".Replace(".", "")
# $url = "http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm${version}c.zip"
# Invoke-WebRequest -Uri "${url}" -OutFile "dmc.zip"
# Expand-Archive -LiteralPath "dmc.zip" -DestinationPath dmc-tmp
# Move-Item -Path dmc-tmp\* -Destination dmc
# working-directory: test
# - name: Compile
# env:
# CC: dmc\bin\dmc.exe
# CXX: dmc\bin\dmc.exe
# run: make -f Makefile.dmc
# working-directory: test

nvhpc:
runs-on: ubuntu-latest
strategy:
matrix:
version:
# For available versions, see
# https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64/Packages
#
# Note that version prior to 21.11 don't support passing
# arguments to the __malloc__ attribute, which glibc >= 2.34,
# which is used in CI, does unconditionally. That causes
# breaks several of the tests for versions prior to 21.11.
# - "20.11"
# - "21.1" ## BROKEN. File size mismatch.
# - "21.2"
# - "21.3"
# - "21.5"
# - "21.7"
# - "21.9"
- "21.11"
# - "22.1"
# - "22.2"
# - "22.3"
# - "22.5"
# - "22.7"
# - "22.9"
- "22.11"
# - "23.1"
# - "23.3"
# - "23.5"
# - "23.7"
# - "23.9"
- "23.11"
# - "24.1"
# - "24.3"
# - "24.7"
steps:
- uses: actions/checkout@v4
- name: Free some disk space
run: sudo rm -rf /usr/local/lib/android /usr/local/.ghcup/ghc
- name: Install NVidia HPC SDK
run: |
curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | sudo tee /etc/apt/sources.list.d/nvhpc.list
sudo apt-get update -y
sudo apt-get install -y nvhpc-$(echo "${{ matrix.version }}" | tr '.' '-')
- name: Compile
env:
CC: /opt/nvidia/hpc_sdk/Linux_x86_64/"${{ matrix.version }}"/compilers/bin/nvc
CXX: /opt/nvidia/hpc_sdk/Linux_x86_64/"${{ matrix.version }}"/compilers/bin/nvc++
working-directory: test
run: make
# nvhpc:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# version:
# # For available versions, see
# # https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64/Packages
# #
# # Note that version prior to 21.11 don't support passing
# # arguments to the __malloc__ atctribute, which glibc >= 2.34,
# # which is used in CI, does unconditionally. That causes
# # breaks several of the tests for versions prior to 21.11.
# # - "20.11"
# # - "21.1" ## BROKEN. File size mismatch.
# # - "21.2"
# # - "21.3"
# # - "21.5"
# # - "21.7"
# # - "21.9"
# - "21.11"
# # - "22.1"
# # - "22.2"
# # - "22.3"
# # - "22.5"
# # - "22.7"
# # - "22.9"
# - "22.11"
# # - "23.1"
# # - "23.3"
# # - "23.5"
# # - "23.7"
# # - "23.9"
# - "23.11"
# # - "24.1"
# # - "24.3"
# # - "24.7"
# steps:
# - uses: actions/checkout@v4
# - name: Free some disk space
# run: sudo rm -rf /usr/local/lib/android /usr/local/.ghcup/ghc
# - name: Install NVidia HPC SDK
# run: |
# curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
# echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | sudo tee /etc/apt/sources.list.d/nvhpc.list
# sudo apt-get update -y
# sudo apt-get install -y nvhpc-$(echo "${{ matrix.version }}" | tr '.' '-')
# - name: Compile
# env:
# CC: /opt/nvidia/hpc_sdk/Linux_x86_64/"${{ matrix.version }}"/compilers/bin/nvc
# CXX: /opt/nvidia/hpc_sdk/Linux_x86_64/"${{ matrix.version }}"/compilers/bin/nvc++
# working-directory: test
# run: make

pelles-c:
runs-on: windows-latest
strategy:
matrix:
version:
# https://community.chocolatey.org/packages/pelles-c#versionhistory
- "12.0.2"
- "11.0.2"
- "10.0.6"
- "9.00.0.0"
# - "8.00.0.0" ## Installation times out.
steps:
- uses: actions/checkout@v2
- name: Install Pelles-C
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install pelles-c --version "${{ matrix.version }}" --no-progress
- name: Compile
env:
CC: 'C:\Program Files\PellesC\bin\pocc.exe'
LD: 'C:\Program Files\PellesC\bin\polink.exe'
CFLAGS: '/IC:\Progra~1\PellesC\Include'
LDFLAGS: '/LIBPATH:C:\Progra~1\PellesC\lib /LIBPATH:C:\Progra~1\PellesC\Lib\Win64'
working-directory: test
run: make -f Makefile.pelles
# pelles-c:
# runs-on: windows-latest
# strategy:
# matrix:
# version:
# # https://community.chocolatey.org/packages/pelles-c#versionhistory
# - "12.0.2"
# - "11.0.2"
# - "10.0.6"
# - "9.00.0.0"
# # - "8.00.0.0" ## Installation times out.
# steps:
# - uses: actions/checkout@v2
# - name: Install Pelles-C
# uses: crazy-max/ghaction-chocolatey@v3
# with:
# args: install pelles-c --version "${{ matrix.version }}" --no-progress
# - name: Compile
# env:
# CC: 'C:\Program Files\PellesC\bin\pocc.exe'
# LD: 'C:\Program Files\PellesC\bin\polink.exe'
# CFLAGS: '/IC:\Progra~1\PellesC\Include'
# LDFLAGS: '/LIBPATH:C:\Progra~1\PellesC\lib /LIBPATH:C:\Progra~1\PellesC\Lib\Win64'
# working-directory: test
# run: make -f Makefile.pelles

tcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Tiny C Compiler
run: |
sudo apt-get install -y tcc
- name: Compile
env:
CC: tcc
working-directory: test
run: make
# tcc:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Install Tiny C Compiler
# run: |
# sudo apt-get install -y tcc
# - name: Compile
# env:
# CC: tcc
# working-directory: test
# run: make

# ti:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# include:
# - tool: ARM
# version: 20.2.7.LTS
# compiler: armcl
# - tool: MSP
# version: 21.6.1.LTS
# compiler: cl430
# - tool: C2000
# version: 22.6.1.LTS
# compiler: cl2000
# - tool: C6000
# version: 8.3.13
# compiler: cl6x
# - tool: C7000
# version: 4.1.0.LTS
# compiler: cl7x
# - tool: PRU
# version: 2.3.3
# compiler: clpru
# steps:
# - uses: actions/checkout@v4
# - name: Install Compiler
# run: |
# curl -s -o installer.bin "$(curl -s "https://www.ti.com/tool/download/${{ matrix.tool }}-CGT/${{ matrix.version }}" | grep -oP 'https://[a-zA-Z0-9\._\-/]+\.bin')"
# chmod u+x installer.bin
# ./installer.bin --mode unattended --unattendedmodeui none --prefix ti-compiler
# mv ti-compiler/* ti-compiler/compiler
# - name: Compile
# env:
# CC: ../ti-compiler/compiler/bin/${{ matrix.compiler }}
# working-directory: test
# run: make

ti:
xlc:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- tool: ARM
version: 20.2.7.LTS
compiler: armcl
- tool: MSP
version: 21.6.1.LTS
compiler: cl430
- tool: C2000
version: 22.6.1.LTS
compiler: cl2000
- tool: C6000
version: 8.3.13
compiler: cl6x
- tool: C7000
version: 4.1.0.LTS
compiler: cl7x
- tool: PRU
version: 2.3.3
compiler: clpru
steps:
- uses: actions/checkout@v4
- name: Install Compiler
run: |
curl -s -o installer.bin "$(curl -s "https://www.ti.com/tool/download/${{ matrix.tool }}-CGT/${{ matrix.version }}" | grep -oP 'https://[a-zA-Z0-9\._\-/]+\.bin')"
chmod u+x installer.bin
./installer.bin --mode unattended --unattendedmodeui none --prefix ti-compiler
mv ti-compiler/* ti-compiler/compiler
- name: Compile
env:
CC: ../ti-compiler/compiler/bin/${{ matrix.compiler }}
working-directory: test
run: make
- uses: uraimo/run-on-arch-action@v2
name: Run commands
id: runcmd
with:
arch: ppc64le
distro: ubuntu22.04
install: |
apt-get update
apt-get install -y curl gnupg make libncurses5
curl -s https://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/ubuntu/public.gpg | apt-key add -
echo "deb https://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/ubuntu/ trusty main" | tee /etc/apt/sources.list.d/ibm-xl-compiler-eval.list
apt-get update
apt-get install -y xlc.16.1.1
/opt/ibm/xlC/16.1.1/bin/xlc_configure <<< 1
env: |
CC: xlc
CXX: xlc++
run: |
cd test
make
9 changes: 7 additions & 2 deletions hedley.h
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,9 @@ HEDLEY_DIAGNOSTIC_POP
#if defined(HEDLEY_UNPREDICTABLE)
# undef HEDLEY_UNPREDICTABLE
#endif
#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
#if \
HEDLEY_HAS_BUILTIN(__builtin_unpredictable) && \
(!defined(HEDLEY_IBM_VERSION) || HEDLEY_IBM_VERSION_CHECK(17,0,0))
# define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
#endif
#if \
Expand Down Expand Up @@ -1969,7 +1971,10 @@ HEDLEY_DIAGNOSTIC_POP
#if defined(HEDLEY_FLAGS)
# undef HEDLEY_FLAGS
#endif
#if HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
#if \
HEDLEY_HAS_ATTRIBUTE(flag_enum) && \
(!defined(__cplusplus) || HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) && \
(!defined(HEDLEY_IBM_VERSION) || HEDLEY_IBM_VERSION_CHECK(17,0,0))
# define HEDLEY_FLAGS __attribute__((__flag_enum__))
#else
# define HEDLEY_FLAGS
Expand Down
6 changes: 5 additions & 1 deletion test/empty-bases.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "../hedley.h"

#if HEDLEY_IAR_VERSION_CHECK(8,0,0)
#if HEDLEY_HAS_WARNING("-Wc++11-extra-semi")
# pragma clang diagnostic warning "-Wc++11-extra-semi"
#elif HEDLEY_HAS_WARNING("-Wextra-semi")
# pragma clang diagnostic warning "-Wextra-semi"
#elif HEDLEY_IAR_VERSION_CHECK(8,0,0)
# pragma diag_suppress=Pe381
#elif defined(HEDLEY_SUNPRO_VERSION) && !defined(__cplusplus)
# pragma error_messages(off,E_EMPTY_DECLARATION)
Expand Down
4 changes: 3 additions & 1 deletion test/static-assert.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "../hedley.h"

#if HEDLEY_IAR_VERSION_CHECK(8,0,0)
#if HEDLEY_HAS_WARNING("-Wextra-semi")
# pragma clang diagnostic warning "-Wextra-semi"
#elif HEDLEY_IAR_VERSION_CHECK(8,0,0)
# pragma diag_suppress=Pe381
#elif defined(HEDLEY_SUNPRO_VERSION) && !defined(__cplusplus)
# pragma error_messages(off,E_EMPTY_DECLARATION)
Expand Down
Loading

0 comments on commit 1db687f

Please sign in to comment.