Skip to content

Commit 0cd7516

Browse files
Andrew Leonardrwestrel
authored andcommitted
8284661: Reproducible assembly builds without relative linking
Backport-of: ab83bceda14f00d2bd9489d33f40aeeafd7572b4
1 parent 06cb8c4 commit 0cd7516

39 files changed

+82
-87
lines changed

make/common/NativeCompilation.gmk

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,20 @@ define SetupCompileNativeFileBody
358358
# Compile as preprocessed assembler file
359359
$1_FLAGS := $(BASIC_ASFLAGS) $$($1_BASE_ASFLAGS)
360360
$1_COMPILER := $(AS)
361+
362+
# gcc assembly files must contain an appropriate relative .file
363+
# path for reproducible builds.
364+
ifeq ($(TOOLCHAIN_TYPE), gcc)
365+
# If no absolute paths allowed, work out relative source file path
366+
# for assembly .file substitution, otherwise use full file path
367+
ifeq ($(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), false)
368+
$1_REL_ASM_SRC := $$(call RelativePath, $$($1_FILE), $(WORKSPACE_ROOT))
369+
else
370+
$1_REL_ASM_SRC := $$($1_FILE)
371+
endif
372+
$1_FLAGS := $$($1_FLAGS) -DASSEMBLY_SRC_FILE='"$$($1_REL_ASM_SRC)"' \
373+
-include $(TOPDIR)/make/data/autoheaders/assemblyprefix.h
374+
endif
361375
else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), )
362376
# Compile as a C++ or Objective-C++ file
363377
$1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CXXFLAGS) \
@@ -1149,19 +1163,6 @@ define SetupNativeCompilationBody
11491163
endif
11501164
endif
11511165

1152-
# Debuginfo of ASM objects always embeds the absolute object path,
1153-
# as ASM debuginfo paths do not get prefix mapped.
1154-
# So for reproducible builds use relative paths to ensure a reproducible
1155-
# debuginfo and libs, when creating debug symbols.
1156-
ifeq ($$(ENABLE_REPRODUCIBLE_BUILD), true)
1157-
ifeq ($(call isTargetOs, linux), true)
1158-
ifeq ($$($1_COMPILE_WITH_DEBUG_SYMBOLS), true)
1159-
$1_LINK_OBJS_RELATIVE := true
1160-
$1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS))
1161-
endif
1162-
endif
1163-
endif
1164-
11651166
$1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
11661167
$$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
11671168

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# This code is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU General Public License version 2 only, as
7+
# published by the Free Software Foundation.
8+
#
9+
# This code is distributed in the hope that it will be useful, but WITHOUT
10+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
# version 2 for more details (a copy is included in the LICENSE file that
13+
# accompanied this code).
14+
#
15+
# You should have received a copy of the GNU General Public License version
16+
# 2 along with this work; if not, write to the Free Software Foundation,
17+
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
#
19+
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
# or visit www.oracle.com if you need additional information or have any
21+
# questions.
22+
#
23+
24+
// ASSEMBLY_SRC_FILE gets replaced by relative or absolute file path
25+
// in NativeCompilation.gmk for gcc tooling on Linux. This ensures a
26+
// reproducible object file through a predictable value of the STT_FILE
27+
// symbol, and subsequently a reproducible .debuginfo.
28+
.file ASSEMBLY_SRC_FILE
29+

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_acos_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_acos.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_acos2_ha_l9_0:

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_asin_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_asin.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_asin2_ha_e9_0:

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_atan2_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_atan2.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_atan22_ha_ex_0:

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_atan_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_atan.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_atan2_ha_e9_0:

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_cbrt_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_cbrt.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_cbrt1_ha_e9_0:

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_cos_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_cos.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_cos2_ha_ex_0:

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_cosh_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_cosh.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_cosh1_ha_e9_0:

src/jdk.incubator.vector/linux/native/libjsvml/jsvml_d_exp_linux_x86.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2018, 2022, Intel Corporation. All rights reserved.
33
* Intel Short Vector Math Library (SVML) Source Code
44
*
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,7 +28,6 @@
2828
#include "globals_vectorApiSupport_linux.S.inc"
2929
#ifdef __VECTOR_API_MATH_INTRINSICS_LINUX
3030
# -- Machine type EM64t
31-
.file "svml_d_exp.c"
3231
.text
3332
..TXTST0:
3433
.L_2__routine_start___jsvml_exp1_ha_e9_0:

0 commit comments

Comments
 (0)