RFR: build pragma error with gcc 4.4.7 (original) (raw)
Kim Barrett kim.barrett at oracle.com
Mon Mar 19 23:23:58 UTC 2018
- Previous message: RFR: build pragma error with gcc 4.4.7
- Next message: RFR: build pragma error with gcc 4.4.7
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mar 16, 2018, at 6:48 AM, Michal Vala <mvala at redhat.com> wrote:
Hi, I've been trying to build latest jdk with gcc 4.4.7 and I hit compile error due to pragma used in function: /mnt/ramdisk/openjdk/src/hotspot/os/linux/oslinux.inline.hpp:103: error: #pragma GCC diagnostic not allowed inside functions
I'm sending little patch that fixes the issue by wrapping whole function. I've also created a macro for ignoring deprecated declaration inside compilerWarnings.hpp to line up with others. Can someone please review? If it's ok, I would also need a sponsor. diff -r 422615764e12 src/hotspot/os/linux/oslinux.inline.hpp --- a/src/hotspot/os/linux/oslinux.inline.hpp Thu Mar 15 14:54:10 2018 -0700 +++ b/src/hotspot/os/linux/oslinux.inline.hpp Fri Mar 16 10:50:24 2018 +0100 @@ -96,13 +96,12 @@ return ::ftruncate64(fd, length); } -inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) -{ // readdirr has been deprecated since glibc 2.24. // See https://sourceware.org/bugzilla/showbug.cgi?id=19056 for more details. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - +PRAGMADIAGPUSH +PRAGMADEPRECATEDIGNORED +inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) +{ dirent* p; int status; assert(dirp != NULL, "just checking"); @@ -114,11 +113,11 @@ if((status = ::readdirr(dirp, dbuf, &p)) != 0) { errno = status; return NULL; - } else + } else { return p; - -#pragma GCC diagnostic pop + } } +PRAGMADIAGPOP inline int os::closedir(DIR *dirp) { assert(dirp != NULL, "argument is NULL"); diff -r 422615764e12 src/hotspot/share/utilities/compilerWarnings.hpp --- a/src/hotspot/share/utilities/compilerWarnings.hpp Thu Mar 15 14:54:10 2018 -0700 +++ b/src/hotspot/share/utilities/compilerWarnings.hpp Fri Mar 16 10:50:24 2018 +0100 @@ -48,6 +48,7 @@ _#define PRAGMAFORMATNONLITERALIGNORED Pragma("GCC diagnostic ignored "-Wformat-nonliteral"") _ Pragma("GCC diagnostic ignored "-Wformat-security"") #define PRAGMAFORMATIGNORED Pragma("GCC diagnostic ignored "-Wformat"") +#define PRAGMADEPRECATEDIGNORED Pragma("GCC diagnostic ignored "-Wdeprecated-declarations"") _#if defined(clangmajor) && _ _(clangmajor >= 4 || _ Thanks! -- Michal Vala OpenJDK QE Red Hat Czech
Given that there seem to be no callers of os::readdir that share the DIR* among multiple threads, it would seem easier to just replace the use of ::readdir_r with ::readdir. That seems to be the intent in the deprecation decision; use ::readdir, and either don't share a DIR* among threads, or use external locking when doing so.
There are also problems with the patch as provided.
(1) Since PRAGMA_DIAG_PUSH/POP do nothing in the version of gcc this change is being made in support of, the warning would be disabled for all following code in any translation unit that includes this file. That doesn't seem good.
(2) The default empty definition for PRAGMA_DEPRECATED_IGNORED is missing. That means the macro can't be used in shared code, in which case having defined in (shared) compilerWarnings.hpp is questionable.
- Previous message: RFR: build pragma error with gcc 4.4.7
- Next message: RFR: build pragma error with gcc 4.4.7
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]