RFR: 8347649: Build fails by clang17 after JDK-8313396

Julian Waters jwaters at openjdk.org
Tue Jan 14 13:16:39 UTC 2025


On Tue, 14 Jan 2025 12:51:56 GMT, SendaoYan <syan at openjdk.org> wrote:

> Hi all,
> This PR fix build failure by clang17 after JDK-8313396. Before this PR file src/hotspot/share/utilities/forbiddenFunctions.hpp `#include <stdlib.h>` and then  `#include "forbiddenFunctions_posix.hpp"`. System header file <stdlib.h> define `realpath` function, and file forbiddenFunctions_posix.hpp add attribute declaration for `realpath` function, so clang17 report compile warning "attribute declaration must precede definition". This PR switch the sequence of `#include <stdlib.h>` and `#include "forbiddenFunctions_posix.hpp"` in file src/hotspot/share/utilities/forbiddenFunctions.hpp to fix this compile warning issue.
> 
> Below code snippet shows the clang17 compile waning:
> 
> void a(const char *, char *){};
> [[deprecated]] void a(const char *, char *);
> 
> 
> clang -Wall -c ~/compiler-test/zzkk/attribute.cpp
> /home/yansendao/compiler-test/zzkk/attribute.cpp:5:3: warning: attribute declaration must precede definition [-Wignored-attributes]
>     5 | [[deprecated]] void a(const char *, char *);
>       |   ^
> /home/yansendao/compiler-test/zzkk/attribute.cpp:4:6: note: previous definition is here
>     4 | void a(const char *, char *){};
>       |      ^
> 1 warning generated.
> 
> 
> Additional testing:
> 
> - [ ] configure and make with gcc10 with release/fastdebug debug level
> - [ ] configure and make with gcc14 with release/fastdebug debug level

I'm not sure this would work, the includes from the system are placed in front of the forbiddenFunctions includes so that the declaration from the system headers are seen first, which I think is needed for the workaround for clang. Pinging @kimbarrett for this

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23102#issuecomment-2589880759


More information about the hotspot-dev mailing list