< prev index next >

make/autoconf/flags-cflags.m4

Print this page

        

@@ -1,7 +1,7 @@
 #
-# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License version 2 only, as
 # published by the Free Software Foundation.  Oracle designates this

@@ -797,19 +797,40 @@
     $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
 
     $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
   fi
 
+  # Calculate offset to use for getting relative paths from __FILE__ macro.
+  # On Windows, this needs to be a Windows path
+  windows_safe_workspace_root="${WORKSPACE_ROOT}"
+  BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([windows_safe_workspace_root])
+  # Add trailing slash if missing
+  workspace_root_trailing_slash="${windows_safe_workspace_root%/}/"
+  FILE_MACRO_OFFSET="${#workspace_root_trailing_slash}"
+  FILE_MACRO_CFLAGS="-DFILE_MACRO_OFFSET=${FILE_MACRO_OFFSET}"
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    # Check if compiler supports -fmacro-prefix-map. If so, use that instead
+    # of FILE_MACRO_OFFSET.
+    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-fmacro-prefix-map=/=/],
+        PREFIX: $3,
+        IF_TRUE: [
+            FILE_MACRO_CFLAGS="-DFILE_MACRO_OFFSET=0 \
+                -fmacro-prefix-map=${workspace_root_trailing_slash}="
+        ]
+    )
+  fi
+
   # EXPORT to API
   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \
       $TOOLCHAIN_CFLAGS_JVM ${$1_TOOLCHAIN_CFLAGS_JVM} \
       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
-      $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
+      $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS"
 
   CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
       $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
-      $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK"
+      $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
+      $FILE_MACRO_CFLAGS"
 
   # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
   # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
   # change in the future.)
 
< prev index next >