Skip to content

Commit 99ef5a3

Browse files
authored
Merge pull request #2521 from LinuxCNC/backport-clang-fixes-from-master
Backport clang fixes from master
2 parents 31fae3b + d59f89b commit 99ef5a3

3 files changed

Lines changed: 41 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,45 @@ jobs:
2626
- run: git fetch --recurse-submodules=no https://github.com/linuxcnc/linuxcnc refs/tags/*:refs/tags/*
2727
- name: Build RIP & test
2828
run: |
29-
./scripts/travis-install-build-deps.sh
29+
set -x
3030
sudo apt-get install -y eatmydata
31-
curl -O https://snapshot.debian.org/archive/debian/20220716T154603Z/pool/main/p/po4a/po4a_0.67-2_all.deb
32-
sudo apt install ./po4a_0.67-2_all.deb
31+
eatmydata ./scripts/travis-install-build-deps.sh
32+
eatmydata curl -O https://snapshot.debian.org/archive/debian/20220716T154603Z/pool/main/p/po4a/po4a_0.67-2_all.deb
33+
sudo eatmydata apt install ./po4a_0.67-2_all.deb
3334
cd src
3435
eatmydata ./autogen.sh
3536
eatmydata ./configure --with-realtime=uspace --disable-check-runtime-deps
3637
eatmydata make -O -j$((1+$(nproc))) default pycheck V=1
3738
# Note that the package build covers html docs
3839
eatmydata ../scripts/rip-environment runtests -p
3940
41+
rip-and-test-clang:
42+
runs-on: ubuntu-20.04
43+
steps:
44+
- name: Dump GitHub context
45+
env:
46+
GITHUB_CONTEXT: ${{ toJson(github) }}
47+
run: echo "$GITHUB_CONTEXT"
48+
- uses: actions/checkout@v2
49+
with:
50+
submodules: true
51+
fetch-depth: 0
52+
- run: git fetch --recurse-submodules=no https://github.com/linuxcnc/linuxcnc refs/tags/*:refs/tags/*
53+
- name: Clang build RIP & test
54+
run: |
55+
set -x
56+
sudo apt-get install -y eatmydata
57+
eatmydata ./scripts/travis-install-build-deps.sh
58+
sudo eatmydata apt-get install -y clang
59+
eatmydata curl -O https://snapshot.debian.org/archive/debian/20220716T154603Z/pool/main/p/po4a/po4a_0.67-2_all.deb
60+
sudo eatmydata apt install ./po4a_0.67-2_all.deb
61+
cd src
62+
eatmydata ./autogen.sh
63+
CC=clang CXX=clang++ eatmydata ./configure --with-realtime=uspace --disable-check-runtime-deps
64+
eatmydata make -O -j$((1+$(nproc))) default pycheck V=1
65+
# Note that the package build covers html docs
66+
eatmydata ../scripts/rip-environment runtests -p
67+
4068
htmldocs:
4169
runs-on: ubuntu-20.04
4270
steps:

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ INCLUDE += $(LIBTIRPC_CFLAGS)
252252
# Compilation options. Perhaps some of these should come from Makefile.inc? (CXXFLAGS now does)
253253
INTEGER_OVERFLOW_FLAGS := -fwrapv
254254
OPT := -Os $(INTEGER_OVERFLOW_FLAGS)
255-
DEBUG := $(DEBUG) -g -Wall -Wno-stringop-truncation -D_FORTIFY_SOURCE=2
255+
DEBUG := $(DEBUG) -g -Wall -D_FORTIFY_SOURCE=2
256256
CFLAGS := $(INCLUDE) $(OPT) $(DEBUG) $(EXTRA_DEBUG) -DULAPI -std=gnu11 -Werror=implicit-function-declaration $(CFLAGS) $(CPPFLAGS)
257257
CXXFLAGS := $(INCLUDE) $(EXTRA_DEBUG) -DULAPI $(DEBUG) $(OPT) -Werror=overloaded-virtual $(CXXFLAGS) $(CPPFLAGS)
258258
CXXFLAGS += -std=gnu++17

src/configure.ac

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if test "$srcdir" != "."; then
3030
AC_MSG_ERROR([Building outside of srcdir is not supported])
3131
fi
3232

33-
AC_PROG_CXX
33+
AC_PROG_CXX([$RTSCC c++ clang++])
3434
AC_PROG_INSTALL
3535

3636
m4_include([m4/ax_require_defined.m4])
@@ -408,6 +408,14 @@ elif ! test `$CC -dumpversion | cut -d '.' -f 1` -gt 2 ; then
408408
AC_MSG_ERROR([Compilers older than gcc 3.x are no longer supported])
409409
fi
410410

411+
# Set flags for C and C++ if supported
412+
for commonflag in -Wno-stringop-truncation ; do
413+
if echo "int main() { return 0;}" | $CC -Werror $commonflag -E - > /dev/null; then
414+
CFLAGS="$CFLAGS $flag"
415+
CXXFLAGS="$CXXFLAGS $flag"
416+
fi
417+
done
418+
411419
AC_MSG_CHECKING([for usability of linux/hidraw.h])
412420
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
413421
#include <sys/ioctl.h>

0 commit comments

Comments
 (0)