Fix clang build error in bitops.c#1794
Merged
hwware merged 3 commits intovalkey-io:unstablefrom Feb 27, 2025
Merged
Conversation
In a recent PR valkey-io#1741 the new header `<immintrin.h>` was added, which transitively includes `<mm_malloc.h>` header, where a function called `_mm_malloc(...)` makes a call to the `malloc` function. The Valkey server code explicitly sets the malloc function as a deprecated function in `server.h`: ```c void *malloc(size_t size) __attribute__((deprecated)); ``` The Valkey server code is then compiled with `-Werror=deprecated-declarations` option to detect the uses of deprecated functions like `malloc`, and due to this, when the `bitops.c` file is compiled with Clang, it fails with the following error: ``` In file included from bitops.c:33: In file included from /usr/lib/llvm-18/lib/clang/18/include/immintrin.h:26: In file included from /usr/lib/llvm-18/lib/clang/18/include/xmmintrin.h:31: /usr/lib/llvm-18/lib/clang/18/include/mm_malloc.h:35:12: error: 'malloc' is deprecated [-Werror,-Wdeprecated-declarations] 35 | return malloc(__size); | ^ ./server.h:3874:42: note: 'malloc' has been explicitly marked deprecated here 3874 | void *malloc(size_t size) __attribute__((deprecated)); ``` There is a difference in behavior though, between GCC and Clang. The `bitops.c` file compiles successfully with GCC. I don't know exactly why GCC does not issue a warning in this case. My best guess is that GCC does not issue warnings from code of the standard library. To fix the build error in clang, we explicitly use `pragma` macro to tell clang to ignore deprecated declarations warnings in `bitops.c`. Signed-off-by: Ricardo Dias <[email protected]>
Signed-off-by: Ricardo Dias <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #1794 +/- ##
============================================
+ Coverage 70.97% 71.13% +0.16%
============================================
Files 123 123
Lines 65645 65648 +3
============================================
+ Hits 46590 46698 +108
+ Misses 19055 18950 -105
|
madolson
reviewed
Feb 27, 2025
Co-authored-by: Madelyn Olson <[email protected]> Signed-off-by: Ricardo Dias <[email protected]>
madolson
approved these changes
Feb 27, 2025
zuiderkwast
pushed a commit
that referenced
this pull request
Mar 18, 2025
In a recent PR #1741 the new header `<immintrin.h>` was added, which transitively includes `<mm_malloc.h>` header, where a function called `_mm_malloc(...)` makes a call to the `malloc` function. The Valkey server code explicitly sets the malloc function as a deprecated function in `server.h`: ```c void *malloc(size_t size) __attribute__((deprecated)); ``` The Valkey server code is then compiled with `-Werror=deprecated-declarations` option to detect the uses of deprecated functions like `malloc`, and due to this, when the `bitops.c` file is compiled with Clang, fails with the following error: ``` In file included from bitops.c:33: In file included from /usr/lib/llvm-18/lib/clang/18/include/immintrin.h:26: In file included from /usr/lib/llvm-18/lib/clang/18/include/xmmintrin.h:31: /usr/lib/llvm-18/lib/clang/18/include/mm_malloc.h:35:12: error: 'malloc' is deprecated [-Werror,-Wdeprecated-declarations] 35 | return malloc(__size); | ^ ./server.h:3874:42: note: 'malloc' has been explicitly marked deprecated here 3874 | void *malloc(size_t size) __attribute__((deprecated)); ``` There is a difference in behavior though, between GCC and Clang. The `bitops.c` file compiles successfully with GCC. I don't know exactly why GCC does not issue a warning in this case. My best guess is that GCC does not issue warnings from code of the standard library. To fix the build error in clang, we explicitly use `pragma` macro to tell clang to ignore deprecated declarations warnings in `bitops.c`. --------- Signed-off-by: Ricardo Dias <[email protected]> Signed-off-by: Ricardo Dias <[email protected]> Co-authored-by: Madelyn Olson <[email protected]>
xbasel
pushed a commit
to xbasel/valkey
that referenced
this pull request
Mar 27, 2025
In a recent PR valkey-io#1741 the new header `<immintrin.h>` was added, which transitively includes `<mm_malloc.h>` header, where a function called `_mm_malloc(...)` makes a call to the `malloc` function. The Valkey server code explicitly sets the malloc function as a deprecated function in `server.h`: ```c void *malloc(size_t size) __attribute__((deprecated)); ``` The Valkey server code is then compiled with `-Werror=deprecated-declarations` option to detect the uses of deprecated functions like `malloc`, and due to this, when the `bitops.c` file is compiled with Clang, fails with the following error: ``` In file included from bitops.c:33: In file included from /usr/lib/llvm-18/lib/clang/18/include/immintrin.h:26: In file included from /usr/lib/llvm-18/lib/clang/18/include/xmmintrin.h:31: /usr/lib/llvm-18/lib/clang/18/include/mm_malloc.h:35:12: error: 'malloc' is deprecated [-Werror,-Wdeprecated-declarations] 35 | return malloc(__size); | ^ ./server.h:3874:42: note: 'malloc' has been explicitly marked deprecated here 3874 | void *malloc(size_t size) __attribute__((deprecated)); ``` There is a difference in behavior though, between GCC and Clang. The `bitops.c` file compiles successfully with GCC. I don't know exactly why GCC does not issue a warning in this case. My best guess is that GCC does not issue warnings from code of the standard library. To fix the build error in clang, we explicitly use `pragma` macro to tell clang to ignore deprecated declarations warnings in `bitops.c`. --------- Signed-off-by: Ricardo Dias <[email protected]> Signed-off-by: Ricardo Dias <[email protected]> Co-authored-by: Madelyn Olson <[email protected]>
xbasel
pushed a commit
to xbasel/valkey
that referenced
this pull request
Mar 27, 2025
In a recent PR valkey-io#1741 the new header `<immintrin.h>` was added, which transitively includes `<mm_malloc.h>` header, where a function called `_mm_malloc(...)` makes a call to the `malloc` function. The Valkey server code explicitly sets the malloc function as a deprecated function in `server.h`: ```c void *malloc(size_t size) __attribute__((deprecated)); ``` The Valkey server code is then compiled with `-Werror=deprecated-declarations` option to detect the uses of deprecated functions like `malloc`, and due to this, when the `bitops.c` file is compiled with Clang, fails with the following error: ``` In file included from bitops.c:33: In file included from /usr/lib/llvm-18/lib/clang/18/include/immintrin.h:26: In file included from /usr/lib/llvm-18/lib/clang/18/include/xmmintrin.h:31: /usr/lib/llvm-18/lib/clang/18/include/mm_malloc.h:35:12: error: 'malloc' is deprecated [-Werror,-Wdeprecated-declarations] 35 | return malloc(__size); | ^ ./server.h:3874:42: note: 'malloc' has been explicitly marked deprecated here 3874 | void *malloc(size_t size) __attribute__((deprecated)); ``` There is a difference in behavior though, between GCC and Clang. The `bitops.c` file compiles successfully with GCC. I don't know exactly why GCC does not issue a warning in this case. My best guess is that GCC does not issue warnings from code of the standard library. To fix the build error in clang, we explicitly use `pragma` macro to tell clang to ignore deprecated declarations warnings in `bitops.c`. --------- Signed-off-by: Ricardo Dias <[email protected]> Signed-off-by: Ricardo Dias <[email protected]> Co-authored-by: Madelyn Olson <[email protected]>
zarkash-aws
pushed a commit
to zarkash-aws/valkey
that referenced
this pull request
Apr 6, 2025
In a recent PR valkey-io#1741 the new header `<immintrin.h>` was added, which transitively includes `<mm_malloc.h>` header, where a function called `_mm_malloc(...)` makes a call to the `malloc` function. The Valkey server code explicitly sets the malloc function as a deprecated function in `server.h`: ```c void *malloc(size_t size) __attribute__((deprecated)); ``` The Valkey server code is then compiled with `-Werror=deprecated-declarations` option to detect the uses of deprecated functions like `malloc`, and due to this, when the `bitops.c` file is compiled with Clang, fails with the following error: ``` In file included from bitops.c:33: In file included from /usr/lib/llvm-18/lib/clang/18/include/immintrin.h:26: In file included from /usr/lib/llvm-18/lib/clang/18/include/xmmintrin.h:31: /usr/lib/llvm-18/lib/clang/18/include/mm_malloc.h:35:12: error: 'malloc' is deprecated [-Werror,-Wdeprecated-declarations] 35 | return malloc(__size); | ^ ./server.h:3874:42: note: 'malloc' has been explicitly marked deprecated here 3874 | void *malloc(size_t size) __attribute__((deprecated)); ``` There is a difference in behavior though, between GCC and Clang. The `bitops.c` file compiles successfully with GCC. I don't know exactly why GCC does not issue a warning in this case. My best guess is that GCC does not issue warnings from code of the standard library. To fix the build error in clang, we explicitly use `pragma` macro to tell clang to ignore deprecated declarations warnings in `bitops.c`. --------- Signed-off-by: Ricardo Dias <[email protected]> Signed-off-by: Ricardo Dias <[email protected]> Co-authored-by: Madelyn Olson <[email protected]> Signed-off-by: Shai Zarka <[email protected]>
murphyjacob4
pushed a commit
to enjoy-binbin/valkey
that referenced
this pull request
Apr 13, 2025
In a recent PR valkey-io#1741 the new header `<immintrin.h>` was added, which transitively includes `<mm_malloc.h>` header, where a function called `_mm_malloc(...)` makes a call to the `malloc` function. The Valkey server code explicitly sets the malloc function as a deprecated function in `server.h`: ```c void *malloc(size_t size) __attribute__((deprecated)); ``` The Valkey server code is then compiled with `-Werror=deprecated-declarations` option to detect the uses of deprecated functions like `malloc`, and due to this, when the `bitops.c` file is compiled with Clang, fails with the following error: ``` In file included from bitops.c:33: In file included from /usr/lib/llvm-18/lib/clang/18/include/immintrin.h:26: In file included from /usr/lib/llvm-18/lib/clang/18/include/xmmintrin.h:31: /usr/lib/llvm-18/lib/clang/18/include/mm_malloc.h:35:12: error: 'malloc' is deprecated [-Werror,-Wdeprecated-declarations] 35 | return malloc(__size); | ^ ./server.h:3874:42: note: 'malloc' has been explicitly marked deprecated here 3874 | void *malloc(size_t size) __attribute__((deprecated)); ``` There is a difference in behavior though, between GCC and Clang. The `bitops.c` file compiles successfully with GCC. I don't know exactly why GCC does not issue a warning in this case. My best guess is that GCC does not issue warnings from code of the standard library. To fix the build error in clang, we explicitly use `pragma` macro to tell clang to ignore deprecated declarations warnings in `bitops.c`. --------- Signed-off-by: Ricardo Dias <[email protected]> Signed-off-by: Ricardo Dias <[email protected]> Co-authored-by: Madelyn Olson <[email protected]>
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.
In a recent PR #1741 the new header
<immintrin.h>was added, which transitively includes<mm_malloc.h>header, where a function called_mm_malloc(...)makes a call to themallocfunction.The Valkey server code explicitly sets the malloc function as a deprecated function in
server.h:The Valkey server code is then compiled with
-Werror=deprecated-declarationsoption to detect the uses of deprecated functions likemalloc, and due to this, when thebitops.cfile is compiled with Clang, fails with the following error:There is a difference in behavior though, between GCC and Clang. The
bitops.cfile compiles successfully with GCC.I don't know exactly why GCC does not issue a warning in this case. My best guess is that GCC does not issue warnings from code of the standard library.
To fix the build error in clang, we explicitly use
pragmamacro to tell clang to ignore deprecated declarations warnings inbitops.c.