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

Header files with conditional behaviour can not be precompiled

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: hs20, 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b131
    • CPU:
      generic
    • OS:
      generic

      Description

      Some of our header files, eg some register_<arch>.hpp files contain code like the following (this is for sparc):

      #ifndef DONT_USE_REGISTER_DEFINES
      #define noreg ((Register)(noreg_RegisterEnumValue))

      #define G0 ((Register)(G0_RegisterEnumValue))
      #define G1 ((Register)(G1_RegisterEnumValue))
      ...
      #endif

      Most files that end up including this won't define DONT_USE_REGISTER_DEFINES, but the actual definition file, register_definitions_sparc.cpp will:

      // make sure the defines don't screw up the declarations later on in this file
      #define DONT_USE_REGISTER_DEFINES

      #include "precompiled.hpp"
      #include "asm/assembler.hpp"
      #include "asm/register.hpp"
      #include "interp_masm_sparc.hpp"
      #include "register_sparc.hpp"

      Note the use of precompiled.hpp. You can not precompile a header whose behaviour depends on #defines that may or may not be set by the files that include it - as there can only be one version of the precompiled header. So this current arrangement is incompatible with use of precompiled headers. (As it is we don't enable precompiled headers for Solaris sparc/x86 when building with Sun Studio, but the problem should be fixed anyway).

      It is not clear to me whether the fix is to try and ensure these header file are excluded from precompiled.hpp; or whether the cpp files that need to modify their behaviour should avoid using precompiled.hpp

      Really we need to audit all headers file that may be precompiled to ensure they only depend on #define's that are build-time constants. It is unclear to me whether the precompilation mechanism is smart enough to determine that a different set of build flags (ie -Dxxxx) is being used when compiling a file versus those used to compile a header that is now pre-compiled.

        Attachments

          Activity

            People

            Assignee:
            dholmes David Holmes
            Reporter:
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: