diff mbox series

[meta-oe] abseil-cpp: fix mingw build

Message ID 20231108142307.1528148-1-samuli.piippo@qt.io
State Under Review
Headers show
Series [meta-oe] abseil-cpp: fix mingw build | expand

Commit Message

Samuli Piippo Nov. 8, 2023, 2:23 p.m. UTC
Add patch to fix mingw build of abseil-cpp

  undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Poke()'
  undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Win32Waiter()'
  undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Post()'
  undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Poke()'

and include bindir to recipe sysroot to fix protobuf build.

|   The imported target "absl::log_severity" references the file
|
|      "../nativesdk-protobuf/4.23.4/recipe-sysroot/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-w64-mingw32/usr/bin/libabsl_log_severity.dll"
|
|   but this file does not exist.

Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
---
 ...workaround-for-MinGW64-build-failure.patch | 28 +++++++++++++++++++
 .../abseil-cpp/abseil-cpp_git.bb              |  3 ++
 2 files changed, 31 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch

Comments

Peter Marko Nov. 8, 2023, 2:53 p.m. UTC | #1
-----Original Message-----
From: openembedded-devel@lists.openembedded.org <openembedded-devel@lists.openembedded.org> On Behalf Of Samuli Piippo via lists.openembedded.org
Sent: Wednesday, November 8, 2023 15:23
To: openembedded-devel@lists.openembedded.org
Cc: jpewhacker@gmail.com
Subject: [oe] [meta-oe][PATCH] abseil-cpp: fix mingw build

> Add patch to fix mingw build of abseil-cpp
>
>   undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Poke()'
>   undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Win32Waiter()'
>   undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Post()'
>   undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Poke()'
>
> and include bindir to recipe sysroot to fix protobuf build.
>
> |   The imported target "absl::log_severity" references the file
> |
> |      "../nativesdk-protobuf/4.23.4/recipe-sysroot/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-w64-mingw32/usr/bin/libabsl_log_severity.dll"
> |
> |   but this file does not exist.
>
> Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
> ---
>  ...workaround-for-MinGW64-build-failure.patch | 28 +++++++++++++++++++
>  .../abseil-cpp/abseil-cpp_git.bb              |  3 ++
>  2 files changed, 31 insertions(+)
>  create mode 100644 meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
>
> diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
> new file mode 100644
> index 000000000..79c2ba7d7
> --- /dev/null
> +++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
> @@ -0,0 +1,28 @@
> +From 2f198d4fd8e0e66a2cd7ef53f62c8c9acf356803 Mon Sep 17 00:00:00 2001
> +From: Samuli Piippo <samuli.piippo@qt.io>
> +Date: Wed, 8 Nov 2023 07:18:37 +0000
> +Subject: [PATCH] Add workaround for MinGW64 build failure
> +
> +Add extra include so that _WIN32_WINNT is defined to correct
> +version when building with MinGW.
> +
> +Fixes #1510
> +
> +Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
> +Upstream-Status: Submitted [https://github.com/abseil/abseil-cpp/pull/1564]
> +---
> + absl/synchronization/internal/win32_waiter.h | 1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/absl/synchronization/internal/win32_waiter.h b/absl/synchronization/internal/win32_waiter.h
> +index 87eb617c..517829e6 100644
> +--- a/absl/synchronization/internal/win32_waiter.h
> ++++ b/absl/synchronization/internal/win32_waiter.h
> +@@ -17,6 +17,7 @@
> + #define ABSL_SYNCHRONIZATION_INTERNAL_WIN32_WAITER_H_
> + 
> + #ifdef _WIN32
> ++#include <windows.h>
> + #include <sdkddkver.h>
> + #endif
> + 
> diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
> index 5003187d0..3e4820642 100644
> --- a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
> +++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
> @@ -15,6 +15,7 @@ SRC_URI = "git://github.com/abseil/abseil-cpp;branch=${BRANCH};protocol=https \
>             file://0002-Remove-maes-option-from-cross-compilation.patch \
>             file://abseil-ppc-fixes.patch \
>             file://0003-Remove-neon-option-from-cross-compilation.patch \
> +           file://0004-Add-workaround-for-MinGW64-build-failure.patch \
>            "
>  
>  S = "${WORKDIR}/git"
> @@ -32,4 +33,6 @@ EXTRA_OECMAKE = "-DBUILD_SHARED_LIBS=ON \
>  
>  BBCLASSEXTEND = "native nativesdk"
>  
> +SYSROOT_DIRS:append:class-nativesdk:mingw32 = "${bindir}"

You need to use leading space if you append.

Additionally, what's the reason for mingw32 override?
I'd expect the binaries to be required (or not required) independently on distro.

And finally, is this correct thing to do?
You should not execute nativesdk binaries as native, you should rather add dependency on abseil-cpp-native to recipe where you have failure without it.

> +
>  FILES:${PN}-dev += "${includedir} ${libdir}/cmake ${libdir}/pkgconfig"
> -- 
> 2.25.1
Samuli Piippo Nov. 8, 2023, 3:33 p.m. UTC | #2
The sysroot addition is not about executables and nothing is trying to run those from the target sysroot. Problem here is that CMake checks that all the installed files are available when using abseil in an another build (protobuf in this case) and complains if the files are not there. See the error in the commit message. 

There is a lengthy thread about SYSROOT_DIR problem of similar nature with protobuf recipe. 


> On 8. Nov 2023, at 16.53, Marko, Peter <Peter.Marko@siemens.com> wrote:
> 
> -----Original Message-----
> From: openembedded-devel@lists.openembedded.org <openembedded-devel@lists.openembedded.org> On Behalf Of Samuli Piippo via lists.openembedded.org
> Sent: Wednesday, November 8, 2023 15:23
> To: openembedded-devel@lists.openembedded.org
> Cc: jpewhacker@gmail.com
> Subject: [oe] [meta-oe][PATCH] abseil-cpp: fix mingw build
> 
>> Add patch to fix mingw build of abseil-cpp
>> undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Poke()'
>> undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Win32Waiter()'
>> undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Post()'
>> undefined reference to `absl::lts_20230802::synchronization_internal::Win32Waiter::Poke()'
>> and include bindir to recipe sysroot to fix protobuf build.
>> |   The imported target "absl::log_severity" references the file
>> |
>> |      "../nativesdk-protobuf/4.23.4/recipe-sysroot/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-w64-mingw32/usr/bin/libabsl_log_severity.dll"
>> |
>> |   but this file does not exist.
>> Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
>> ---
>> ...workaround-for-MinGW64-build-failure.patch | 28 +++++++++++++++++++
>> .../abseil-cpp/abseil-cpp_git.bb              |  3 ++
>> 2 files changed, 31 insertions(+)
>> create mode 100644 meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
>> diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
>> new file mode 100644
>> index 000000000..79c2ba7d7
>> --- /dev/null
>> +++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
>> @@ -0,0 +1,28 @@
>> +From 2f198d4fd8e0e66a2cd7ef53f62c8c9acf356803 Mon Sep 17 00:00:00 2001
>> +From: Samuli Piippo <samuli.piippo@qt.io>
>> +Date: Wed, 8 Nov 2023 07:18:37 +0000
>> +Subject: [PATCH] Add workaround for MinGW64 build failure
>> +
>> +Add extra include so that _WIN32_WINNT is defined to correct
>> +version when building with MinGW.
>> +
>> +Fixes #1510
>> +
>> +Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
>> +Upstream-Status: Submitted [https://github.com/abseil/abseil-cpp/pull/1564]
>> +---
>> + absl/synchronization/internal/win32_waiter.h | 1 +
>> + 1 file changed, 1 insertion(+)
>> +
>> +diff --git a/absl/synchronization/internal/win32_waiter.h b/absl/synchronization/internal/win32_waiter.h
>> +index 87eb617c..517829e6 100644
>> +--- a/absl/synchronization/internal/win32_waiter.h
>> ++++ b/absl/synchronization/internal/win32_waiter.h
>> +@@ -17,6 +17,7 @@
>> + #define ABSL_SYNCHRONIZATION_INTERNAL_WIN32_WAITER_H_
>> +
>> + #ifdef _WIN32
>> ++#include <windows.h>
>> + #include <sdkddkver.h>
>> + #endif
>> +
>> diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
>> index 5003187d0..3e4820642 100644
>> --- a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
>> +++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
>> @@ -15,6 +15,7 @@ SRC_URI = "git://github.com/abseil/abseil-cpp;branch=${BRANCH};protocol=https \
>>          file://0002-Remove-maes-option-from-cross-compilation.patch \
>>          file://abseil-ppc-fixes.patch \
>>          file://0003-Remove-neon-option-from-cross-compilation.patch \
>> +           file://0004-Add-workaround-for-MinGW64-build-failure.patch \
>>         "
>> S = "${WORKDIR}/git"
>> @@ -32,4 +33,6 @@ EXTRA_OECMAKE = "-DBUILD_SHARED_LIBS=ON \
>> BBCLASSEXTEND = "native nativesdk"
>> +SYSROOT_DIRS:append:class-nativesdk:mingw32 = "${bindir}"
> 
> You need to use leading space if you append.
> 
> Additionally, what's the reason for mingw32 override?
> I'd expect the binaries to be required (or not required) independently on distro.
> 
> And finally, is this correct thing to do?
> You should not execute nativesdk binaries as native, you should rather add dependency on abseil-cpp-native to recipe where you have failure without it.
> 
>> +
>> FILES:${PN}-dev += "${includedir} ${libdir}/cmake ${libdir}/pkgconfig"
>> --
>> 2.25.1
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
new file mode 100644
index 000000000..79c2ba7d7
--- /dev/null
+++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-Add-workaround-for-MinGW64-build-failure.patch
@@ -0,0 +1,28 @@ 
+From 2f198d4fd8e0e66a2cd7ef53f62c8c9acf356803 Mon Sep 17 00:00:00 2001
+From: Samuli Piippo <samuli.piippo@qt.io>
+Date: Wed, 8 Nov 2023 07:18:37 +0000
+Subject: [PATCH] Add workaround for MinGW64 build failure
+
+Add extra include so that _WIN32_WINNT is defined to correct
+version when building with MinGW.
+
+Fixes #1510
+
+Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
+Upstream-Status: Submitted [https://github.com/abseil/abseil-cpp/pull/1564]
+---
+ absl/synchronization/internal/win32_waiter.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/absl/synchronization/internal/win32_waiter.h b/absl/synchronization/internal/win32_waiter.h
+index 87eb617c..517829e6 100644
+--- a/absl/synchronization/internal/win32_waiter.h
++++ b/absl/synchronization/internal/win32_waiter.h
+@@ -17,6 +17,7 @@
+ #define ABSL_SYNCHRONIZATION_INTERNAL_WIN32_WAITER_H_
+ 
+ #ifdef _WIN32
++#include <windows.h>
+ #include <sdkddkver.h>
+ #endif
+ 
diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
index 5003187d0..3e4820642 100644
--- a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
+++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_git.bb
@@ -15,6 +15,7 @@  SRC_URI = "git://github.com/abseil/abseil-cpp;branch=${BRANCH};protocol=https \
            file://0002-Remove-maes-option-from-cross-compilation.patch \
            file://abseil-ppc-fixes.patch \
            file://0003-Remove-neon-option-from-cross-compilation.patch \
+           file://0004-Add-workaround-for-MinGW64-build-failure.patch \
           "
 
 S = "${WORKDIR}/git"
@@ -32,4 +33,6 @@  EXTRA_OECMAKE = "-DBUILD_SHARED_LIBS=ON \
 
 BBCLASSEXTEND = "native nativesdk"
 
+SYSROOT_DIRS:append:class-nativesdk:mingw32 = "${bindir}"
+
 FILES:${PN}-dev += "${includedir} ${libdir}/cmake ${libdir}/pkgconfig"