Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8087156

SetupNativeCompilation ignores CFLAGS_release for cpp files

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • None
    • infrastructure
    • b69

        The SetupNativeCompilation macro's documentation states:

            # CFLAGS the compiler flags to be used, used both for C and C++.
            # CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS.

        Unfortunately, this doesn't work in all case. This is the code that implements what is described above (the relevant code is the last bit, but the code that comes before it causes a problem):

          ifeq ($$($1_DEBUG_SYMBOLS), true)
            ifeq ($(ENABLE_DEBUG_SYMBOLS), true)
              ifdef OPENJDK
                # Always add debug symbols
                $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS)
                $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS)
              else
                # Programs don't get the debug symbols added in the old build. It's not clear if
                # this is intentional.
                ifeq ($$($1_PROGRAM),)
                  $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS)
                  $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS)
                endif
              endif
            endif
          endif

          # If no C++ flags are explicitly set, default to using the C flags.
          # After that, we can set additional C++ flags that should not interfere
          # with the mechanism for copying the C flags by default.
          ifeq ($$($1_CXXFLAGS),)
            $1_CXXFLAGS:=$$($1_CFLAGS)
          endif
          ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)),)
            $1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS)
          endif

        The code only sets $1_EXTRA_CXXFLAGS if it is empty. But depending on the debugging settings, it may have been initialized in the code just above it (with only debugging-related options)

        The fix is to only set debugging options in $1_EXTRA_CXXFLAGS after initializing it with $1_EXTRA_CFLAGS.

              omajid Omair Majid
              omajid Omair Majid
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: