From c34fee06482775768ae1478d58693a0a33013ee8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 10 Mar 2026 09:31:21 +0100 Subject: [PATCH 1/5] set clang as default compiler in build files --- CMakeLists.txt | 11 +++++++++-- Makefile | 26 ++++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cb79ae46..a6f4d4aef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ set(CMAKE_C_STANDARD 99) if(UNIX) set(TARGET_PLATFORM "" CACHE STRING "i686 / x86_64") set(CLANG "" CACHE STRING "1=msan / 2=asan / 3=usan") + set(GCC "" CACHE STRING "1=use gcc instead of default (clang)") set(GCOV OFF CACHE BOOL "enable GCOV") set(STRIP OFF CACHE BOOL "enable STRIP") @@ -62,10 +63,16 @@ if(UNIX) # to be uncommented in CI # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + # set C compiler + if(GCC OR GCOV) + find_program(cc NAMES gcc-13 gcc REQUIRED) + else() + find_program(cc NAMES clang-18 clang REQUIRED) + endif() + set(CMAKE_C_COMPILER "${cc}" CACHE STRING "") + # CLANG if(CLANG) - find_program(clangBin NAMES /home/amm-archiv/soft/Linux/clang/current/bin/clang clang REQUIRED) - set(CMAKE_C_COMPILER "${clangBin}" CACHE STRING "") if("${CLANG}" MATCHES "1" OR "${CLANG}" MATCHES "msan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory") diff --git a/Makefile b/Makefile index c9ae4493d..44f14d6e2 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ LIB_LC3PLUS ?= liblc3plus.a LIB_LIBUTIL ?= libivasutil.a # Default tool settings -CC ?= gcc +CC ?= cc RM ?= rm -f AR ?= ar @@ -74,23 +74,31 @@ CFLAGS += -Wunused-but-set-variable # libs to link LDLIBS += -lm +# check if clang is available on system and use it if it is there +CLANG_EXISTS := $(shell which clang) + +ifneq "$(CLANG_EXISTS)" "" +CC = clang +else +$(warning clang compiler not found - falling back to cc) +endif + # Clang sanitizer compiler options -CCCLANG = clang ifeq "$(CLANG)" "0" -CC = $(CCCLANG) +CC = clang endif ifeq "$(CLANG)" "1" -CC = $(CCCLANG) +CC = clang CFLAGS += -fsanitize=memory LDFLAGS += -fsanitize=memory endif ifeq "$(CLANG)" "2" -CC = $(CCCLANG) +CC = clang CFLAGS += -fsanitize=address LDFLAGS += -fsanitize=address endif ifeq "$(CLANG)" "3" -CC = $(CCCLANG) +CC = clang # NOTE: keep in sync with list in CMakeLists.txt usan_checks = undefined,float-divide-by-zero,implicit-conversion,local-bounds CFLAGS += -fsanitize=$(usan_checks) @@ -104,6 +112,11 @@ LDFLAGS += -fsanitize-ignorelist=ubsan_ignorelist.txt endif endif +# check if explicitly gcc is mandated +ifneq "$(GCC)" "" +CC = gcc +endif + ifeq "$(RELEASE)" "1" CFLAGS += -DRELEASE OPTIM ?= 2 @@ -115,6 +128,7 @@ LDFLAGS += -g3 endif ifeq "$(GCOV)" "1" +CC = gcc CFLAGS += -fprofile-arcs -ftest-coverage -fprofile-update=atomic LDFLAGS += -fprofile-arcs -ftest-coverage -fprofile-update=atomic endif -- GitLab From 8bfe7d772be21612d60653ca8f1e6619761fe4bb Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 23 Mar 2026 11:15:44 +0100 Subject: [PATCH 2/5] synch with float --- CMakeLists.txt | 13 +++++++++---- Makefile | 17 ++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6f4d4aef..5976c7ebd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,8 @@ if(UNIX) set(TARGET_PLATFORM "" CACHE STRING "i686 / x86_64") set(CLANG "" CACHE STRING "1=msan / 2=asan / 3=usan") set(GCC "" CACHE STRING "1=use gcc instead of default (clang)") - set(GCOV OFF CACHE BOOL "enable GCOV") + set(MSAN_TRACK_ORIGINS OFF CACHE BOOL "enable origin tracking for Clang MSAN") + set(COVERAGE OFF CACHE BOOL "enable coverage instrumentation") set(STRIP OFF CACHE BOOL "enable STRIP") if(NOT CMAKE_BUILD_TYPE) @@ -64,7 +65,7 @@ if(UNIX) # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") # set C compiler - if(GCC OR GCOV) + if(GCC) find_program(cc NAMES gcc-13 gcc REQUIRED) else() find_program(cc NAMES clang-18 clang REQUIRED) @@ -76,6 +77,10 @@ if(UNIX) if("${CLANG}" MATCHES "1" OR "${CLANG}" MATCHES "msan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory") + if(MSAN_TRACK_ORIGINS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-memory-track-origins") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize-memory-track-origins") + endif() elseif("${CLANG}" MATCHES "2" OR "${CLANG}" MATCHES "asan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") @@ -96,8 +101,8 @@ if(UNIX) message(FATAL_ERROR "Unknown CLANG setting: ${CLANG}") endif() endif() - # GCOV - if(GCOV) + # COVERAGE + if(COVERAGE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage -fprofile-update=atomic") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -fprofile-update=atomic") endif() diff --git a/Makefile b/Makefile index 44f14d6e2..ed4187dcb 100644 --- a/Makefile +++ b/Makefile @@ -65,11 +65,10 @@ endif CFLAGS += -std=c99 -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \ -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ -Werror-implicit-function-declaration \ - -Wno-implicit-fallthrough -ffp-contract=off + -Wno-implicit-fallthrough -ffp-contract=off \ + -Winit-self -Wunused-but-set-variable # to be uncommented in CI # CFLAGS += -Werror -CFLAGS += -Winit-self -CFLAGS += -Wunused-but-set-variable # libs to link LDLIBS += -lm @@ -84,13 +83,17 @@ $(warning clang compiler not found - falling back to cc) endif # Clang sanitizer compiler options -ifeq "$(CLANG)" "0" -CC = clang -endif ifeq "$(CLANG)" "1" CC = clang CFLAGS += -fsanitize=memory LDFLAGS += -fsanitize=memory + +# can be set in call to make, e.g. "make CLANG=1 MSAN_TRACK_ORIGINS=1" +ifeq "$(MSAN_TRACK_ORIGINS)" "1" +CFLAGS += -fsanitize-memory-track-origins +LDFLAGS += -fsanitize-memory-track-origins +endif + endif ifeq "$(CLANG)" "2" CC = clang @@ -127,7 +130,7 @@ CFLAGS += -g3 LDFLAGS += -g3 endif -ifeq "$(GCOV)" "1" +ifeq "$(COVERAGE)" "1" CC = gcc CFLAGS += -fprofile-arcs -ftest-coverage -fprofile-update=atomic LDFLAGS += -fprofile-arcs -ftest-coverage -fprofile-update=atomic -- GitLab From aceae1ead902c8850f63e0971734c2bebf1b94c1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 23 Mar 2026 11:24:16 +0100 Subject: [PATCH 3/5] [revert-me] change CI ref --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f84bc99f..99993c0b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF ci/use-llvm-cov # If you need to set some config variable only in a local branch, then add an overwrite here # One example is DISABLE_HRTF - this will be set on a branch which is about to be merged and will be removed in a subsequent second MR # this is more easily done directly here in the child repo -- GitLab From a46b8e3cb755341f73d71530e54130968278a2e9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Mar 2026 09:24:38 +0100 Subject: [PATCH 4/5] remove GCC input --- CMakeLists.txt | 7 +------ Makefile | 5 ----- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5976c7ebd..70c4a6e20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ set(CMAKE_C_STANDARD 99) if(UNIX) set(TARGET_PLATFORM "" CACHE STRING "i686 / x86_64") set(CLANG "" CACHE STRING "1=msan / 2=asan / 3=usan") - set(GCC "" CACHE STRING "1=use gcc instead of default (clang)") set(MSAN_TRACK_ORIGINS OFF CACHE BOOL "enable origin tracking for Clang MSAN") set(COVERAGE OFF CACHE BOOL "enable coverage instrumentation") set(STRIP OFF CACHE BOOL "enable STRIP") @@ -65,11 +64,7 @@ if(UNIX) # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") # set C compiler - if(GCC) - find_program(cc NAMES gcc-13 gcc REQUIRED) - else() - find_program(cc NAMES clang-18 clang REQUIRED) - endif() + find_program(cc NAMES clang-18 clang REQUIRED) set(CMAKE_C_COMPILER "${cc}" CACHE STRING "") # CLANG diff --git a/Makefile b/Makefile index ed4187dcb..a9a939742 100644 --- a/Makefile +++ b/Makefile @@ -115,11 +115,6 @@ LDFLAGS += -fsanitize-ignorelist=ubsan_ignorelist.txt endif endif -# check if explicitly gcc is mandated -ifneq "$(GCC)" "" -CC = gcc -endif - ifeq "$(RELEASE)" "1" CFLAGS += -DRELEASE OPTIM ?= 2 -- GitLab From 98c19dfd24c18dc9b7c429ac72e51f34f9b6a452 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Mar 2026 14:02:20 +0100 Subject: [PATCH 5/5] Revert "[revert-me] change CI ref" This reverts commit aceae1ead902c8850f63e0971734c2bebf1b94c1. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 99993c0b8..3f84bc99f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF ci/use-llvm-cov + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main # If you need to set some config variable only in a local branch, then add an overwrite here # One example is DISABLE_HRTF - this will be set on a branch which is about to be merged and will be removed in a subsequent second MR # this is more easily done directly here in the child repo -- GitLab