Build libjpeg-turbo reproducibly
cover Build libjpeg-turbo reproducibly
Apply patches to nasm that allow changing the debug prefix in generated output files, then use this option to make sure libjpeg-turbo builds reproducibly.
Joshua Watt (2):
nasm: Add debug-prefix-map option
libjpeg-turbo: Build reproducibly
.../nasm/nasm/0001-stdlib-Add-strlcat.patch | 117 +++++++ .../0002-Add-debug-prefix-map-option.patch | 325 ++++++++++++++++++ meta/recipes-devtools/nasm/nasm_2.14.02.bb | 2 + .../jpeg/libjpeg-turbo_2.0.3.bb | 2 + 4 files changed, 446 insertions(+) create mode 100644 meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch create mode 100644 meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
Signature · 1 line
2.23.0
PATCH 1/2 nasm: Add debug-prefix-map option
Adds an option to nasm to change the prefix for file paths encoded in the object files. This allows builds to be reproducible regardless of the build directory.
Signed-off-by Joshua Watt <[email protected]>
--- .../nasm/nasm/0001-stdlib-Add-strlcat.patch | 117 +++++++ .../0002-Add-debug-prefix-map-option.patch | 325 ++++++++++++++++++ meta/recipes-devtools/nasm/nasm_2.14.02.bb | 2 + 3 files changed, 444 insertions(+) create mode 100644 meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch create mode 100644 meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch new file +117 -0
@@ -0,0 +1,117 @@ +From 8a204171004fa0d7d21389530c744d215e99efb0 Mon Sep 17 00:00:00 2001 +From: Joshua Watt <[email protected]> +Date: Tue, 19 Nov 2019 12:47:30 -0600 +Subject: [PATCH 1/2] stdlib: Add strlcat + +Adds strlcat which can be used to safely concatenate strings + +Upstream-Status: Submitted [https://bugzilla.nasm.us/show_bug.cgi?id=3392635] +Signed-off-by: Joshua Watt <[email protected]> +--- + Makefile.in | 2 +- + configure.ac | 2 ++ + include/compiler.h | 4 ++++ + stdlib/strlcat.c | 43 +++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 50 insertions(+), 1 deletion(-) + create mode 100644 stdlib/strlcat.c + +diff --git a/Makefile.in b/Makefile.in +index 32ef3d91..ff7eb447 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -93,7 +93,7 @@ NASM = asm/nasm.$(O) + NDISASM = disasm/ndisasm.$(O) + + LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ +- stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \ ++ stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) stdlib/strlcat.$(O) \ + \ + nasmlib/ver.$(O) \ + nasmlib/crc64.$(O) nasmlib/malloc.$(O) nasmlib/errfile.$(O) \ +diff --git a/configure.ac b/configure.ac +index 38b3b596..b4e88778 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -152,6 +152,7 @@ AC_CHECK_FUNCS([vsnprintf _vsnprintf]) + AC_CHECK_FUNCS([snprintf _snprintf]) + AC_CHECK_FUNCS([strlcpy]) + AC_CHECK_FUNCS([strrchrnul]) ++AC_CHECK_FUNCS([strlcat]) + + dnl These types are POSIX-specific, and Windows does it differently... + AC_CHECK_TYPES([struct _stati64]) +@@ -170,6 +171,7 @@ AC_CHECK_DECLS(strsep) + AC_CHECK_DECLS(strlcpy) + AC_CHECK_DECLS(strnlen) + AC_CHECK_DECLS(strrchrnul) ++AC_CHECK_DECLS(strlcat) + + dnl Check for missing types + AC_TYPE_UINTPTR_T +diff --git a/include/compiler.h b/include/compiler.h +index 4178c98e..8153d297 100644 +--- a/include/compiler.h ++++ b/include/compiler.h +@@ -159,6 +159,10 @@ size_t strlcpy(char *, const char *, size_t); + char *strrchrnul(const char *, int); + #endif + ++#if !defined(HAVE_STRLCAT) || !HAVE_DECL_STRLCAT ++size_t strlcat(char *, const char *, size_t); ++#endif ++ + #ifndef __cplusplus /* C++ has false, true, bool as keywords */ + # ifdef HAVE_STDBOOL_H + # include <stdbool.h> +diff --git a/stdlib/strlcat.c b/stdlib/strlcat.c +new file mode 100644 +index 00000000..7084d460 +--- /dev/null ++++ b/stdlib/strlcat.c +@@ -0,0 +1,43 @@ ++/* ++ * Copyright (c) 2019 Garmin Ltd. or its subsidiaries ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include "compiler.h" ++ ++/* ++ * Concatenate src string to dest of size size. The destination buffer will ++ * have no more than size-1 character when the operation finishes. Always NUL ++ * terminates, unless size == 0 or dest has no NUL terminator. Returns ++ * strlen(initial dest) + strlen(src); if retval >= size, truncation occurred. ++ */ ++#ifndef HAVE_STRLCAT ++ ++size_t strlcat(char *dest, const char *src, size_t size) ++{ ++ size_t n; ++ ++ /* find the NULL terminator in dest */ ++ for (n = 0; i < size && dest[n] != '\0'; n++) ++ ; ++ ++ /* destination was not NULL terminated. Return the initial size */ ++ if (n == size) ++ return size; ++ ++ return strlcpy(&dest[n], src, size - n) + n; ++} ++ ++#endif ++ +-- +2.23.0 +
meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch new file +325 -0
325 lines not on this page · raw message
meta/recipes-devtools/nasm/nasm_2.14.02.bb +2 -0
@@ -6,6 +6,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=90904486f8fbf1861cf42752e1a39efe" SRC_URI = "http://www.nasm.us/pub/nasm/releasebuilds/${PV}/nasm-${PV}.tar.bz2 \ file://CVE-2018-19755.patch \ file://CVE-2019-14248.patch \ + file://0001-stdlib-Add-strlcat.patch \ + file://0002-Add-debug-prefix-map-option.patch \ " SRC_URI[md5sum] = "3f489aa48ad2aa1f967dc5e293bbd06f"
Signature · 1 line
2.23.0
PATCH 2/2 libjpeg-turbo: Build reproducibly
In reply to Joshua WattConfigures the options passed to nasm to remove build paths in the generated object files.
Signed-off-by Joshua Watt <[email protected]>
--- meta/recipes-graphics/jpeg/libjpeg-turbo_2.0.3.bb | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-graphics/jpeg/libjpeg-turbo_2.0.3.bb +2 -0
@@ -29,6 +29,8 @@ RCONFLICTS_${PN} += "jpeg" inherit cmake pkgconfig +export NASMENV = "--debug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" + # Add nasm-native dependency consistently for all build arches is hard EXTRA_OECMAKE_append_class-native = " -DWITH_SIMD=False" EXTRA_OECMAKE_append_class-nativesdk = " -DWITH_SIMD=False"
Signature · 1 line
2.23.0