Fix all -Wimplicit-function-declaration errors for GCC 14+#34
Open
P4o1o wants to merge 2 commits intoOpenMathLib:masterfrom
Open
Fix all -Wimplicit-function-declaration errors for GCC 14+#34P4o1o wants to merge 2 commits intoOpenMathLib:masterfrom
P4o1o wants to merge 2 commits intoOpenMathLib:masterfrom
Conversation
GCC 14 made implicit function declarations an error by default. This broke the OpenVML build in three places: 1. include/openvml_kernel.h: typo 'sdqr_k' instead of 'dsqr_k' for the double-precision sqr kernel declaration. 2. kernel/generic/exp10_kernel.c, reference/vexp10.c: exp10/exp10f are GNU extensions requiring _GNU_SOURCE to be defined before including math.h. 3. test/vml_util.c: missing #include "cycle.h" for get_cycles() declaration. On GCC <= 13 these were warnings; on GCC 14+ (Fedora 40+, CentOS Stream 10, etc.) they are fatal errors.
GCC 14 made implicit function declarations an error by default. This broke the OpenVML build in three places: 1. include/openvml_kernel.h: typo 'sdqr_k' instead of 'dsqr_k' for the double-precision sqr kernel declaration. 2. kernel/generic/exp10_kernel.c, reference/vexp10.c: exp10/exp10f are GNU extensions requiring _GNU_SOURCE to be defined before including math.h. 3. test/vml_util.c: missing #include "cycle.h" for get_cycles() declaration. On GCC <= 13 these were warnings; on GCC 14+ (Fedora 40+, CentOS Stream 10, etc.) they are fatal errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #33
Problem
Starting with GCC 14,
-Wimplicit-function-declarationwas promoted fromwarning to error by default. This breaks the OpenVML build on all modern
distributions shipping GCC 14+ (Fedora 40+, CentOS Stream 10, Ubuntu 24.10+,
Arch, etc.).
On GCC ≤ 13 these were only warnings, so the build would succeed and all
tests passed — masking the underlying bugs.
This PR fixes all three implicit declaration issues at once, so that
the build actually succeeds end-to-end on GCC 14+.
Changes
1. Fix typo
sdqr_k→dsqr_k(include/openvml_kernel.h)The double-precision sqr kernel was declared as
sdqr_kinstead ofdsqr_k.Every other kernel in the project follows the naming convention
s<func>_k(float),d<func>_k(double),c<func>_k(complex float),z<func>_k(complex double). For example:sadd_k/dadd_k,ssub_k/dsub_k,spow_k/dpow_k.The macros in
openvml_macros.hcorrectly defineDSQR_Kasdsqr_k,but the prototype in
openvml_kernel.hdeclaredsdqr_k— a simpletransposition of the "s" and "d" prefixes.
2. Fix
exp10/exp10fimplicit declarations (openvml_common.h+ include reordering)exp10()andexp10f()are GNU extensions. Their prototypes are onlyexposed by
<math.h>when_GNU_SOURCEis defined. The project neverdefined this macro, so the prototypes were invisible to the compiler.
Approach: rather than sprinkling
#define _GNU_SOURCEin each individualsource file, I defined it once in
include/openvml_common.h, which isthe project-wide common header included (directly or transitively) by all
source files. This is the cleanest and most maintainable solution — any
future GNU extension usage will also be covered.
Additionally, several files in
kernel/generic/andreference/had<math.h>included before"openvml_kernel.h"(which transitivelyincludes
openvml_common.h). This meant_GNU_SOURCEwas not yet definedwhen
<math.h>was processed. I reordered the includes so that theproject's own headers come first:
This follows the widely accepted best practice of including project/local
headers before system headers, ensuring that project-wide defines are
active before any system header is parsed.
Affected files:
include/openvml_common.h(added#define _GNU_SOURCE)kernel/generic/*.c(reordered includes where needed)reference/vexp10.c(reordered includes)3. Fix
get_cyclesimplicit declaration (test/vml_util.c)get_cycles()is defined intest/cycle.cand declared intest/cycle.h,but
test/cycle.hhad a typo in the preprocessor definition.#ifdef _OPENVML_CYCLE_H_ +#ifndef _OPENVML_CYCLE_H_Same error in
test/openvml_timer.h#ifdef _OPENVML_TIMER_H_ +#ifndef _OPENVML_TIMER_H_Why a single PR
All three issues produce the same compiler error (
-Wimplicit-function-declaration)and have the same root cause: GCC 14 turning this from a warning into an error.
Fixing only one would still leave the build broken on GCC 14+, so it makes
sense to address them together. The issue #33 is not truly resolved unless
all three are fixed.
Testing
make clean && make) completes with zero-Wimplicit-function-declarationwarnings/errorsrun_vml_testtests passconfirming backward compatibility)