diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/open-vmdk/files/vmdk-fix-build-issues-with-gcc-10-or-newer.patch b/sdk_container/src/third_party/coreos-overlay/app-emulation/open-vmdk/files/vmdk-fix-build-issues-with-gcc-10-or-newer.patch new file mode 100644 index 0000000000..67ff8c0981 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/open-vmdk/files/vmdk-fix-build-issues-with-gcc-10-or-newer.patch @@ -0,0 +1,51 @@ +From 74dffbca5d6fa37ed4ecd9b3a75206e33497e3df Mon Sep 17 00:00:00 2001 +Message-Id: <74dffbca5d6fa37ed4ecd9b3a75206e33497e3df.1644245904.git.dpark@linux.microsoft.com> +From: Dongsu Park +Date: Mon, 7 Feb 2022 15:44:24 +0100 +Subject: [PATCH] vmdk: fix build issues with gcc 10 or newer + +As gcc 10 or newer defaults to `-fno-common`, we need to define only +once in a *.c file, instead of *.h that can be imported multiple times +by *.c files. + +Otherwise, build would fail like: +``` +.../x86_64-pc-linux-gnu/bin/ld: +../build/vmdk/mkdisk.o:.../vmdk/diskinfo.h:38: +multiple definition of `toolsVersion'; +../build/vmdk/flat.o:.../vmdk/diskinfo.h:38: first defined here +``` +--- + vmdk/diskinfo.h | 2 +- + vmdk/mkdisk.c | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/vmdk/diskinfo.h b/vmdk/diskinfo.h +index 2b58f432..f4f94419 100644 +--- a/vmdk/diskinfo.h ++++ b/vmdk/diskinfo.h +@@ -35,7 +35,7 @@ struct DiskInfo { + const DiskInfoVMT *vmt; + }; + +-char *toolsVersion; /* toolsVersion in metadata */ ++extern char *toolsVersion; /* toolsVersion in metadata */ + + DiskInfo *Flat_Open(const char *fileName); + DiskInfo *Flat_Create(const char *fileName, off_t capacity); +diff --git a/vmdk/mkdisk.c b/vmdk/mkdisk.c +index b6c0cc94..b66b7d5d 100644 +--- a/vmdk/mkdisk.c ++++ b/vmdk/mkdisk.c +@@ -24,6 +24,8 @@ + #include + #include + ++char *toolsVersion; /* toolsVersion in metadata */ ++ + static int + copyData(DiskInfo *dst, + off_t dstOffset, +-- +2.34.1 + diff --git a/sdk_container/src/third_party/coreos-overlay/app-emulation/open-vmdk/open-vmdk-1.0.ebuild b/sdk_container/src/third_party/coreos-overlay/app-emulation/open-vmdk/open-vmdk-1.0.ebuild index 44916caa32..c8f7ac1e52 100644 --- a/sdk_container/src/third_party/coreos-overlay/app-emulation/open-vmdk/open-vmdk-1.0.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/app-emulation/open-vmdk/open-vmdk-1.0.ebuild @@ -21,6 +21,10 @@ IUSE="" DEPEND="" RDEPEND="${DEPEND}" +PATCHES=( + "${FILESDIR}/vmdk-fix-build-issues-with-gcc-10-or-newer.patch" +) + src_install() { emake DESTDIR="${D}" install }