All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-python][PATCH] python3-posix-ipc: use correct C compiler to detect system features
@ 2025-01-25 12:44 Gyorgy Sarvari
  2025-01-25 15:08 ` Guðni Már Gilbert
  0 siblings, 1 reply; 2+ messages in thread
From: Gyorgy Sarvari @ 2025-01-25 12:44 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Gyorgy Sarvari

During compilation, prober.py (called from setup.py) uses "cc" to
compile some simple code, to detect if the used features are available.
However during cross-compilation we don't use "cc", but some other
compiler for cross-compiling.

Due to this, the feature detection can fail (maybe it fails always?),
as the correct C compiler for Yocto is not cc, but the content of
CC environment variable.

To solve this, instead of using cc always, take the C compiler from the CC
environment variable when it is available, and fall back to cc only
when this environment variable is not set.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 ...default-cc-from-environment-variable.patch | 45 +++++++++++++++++++
 .../python/python3-posix-ipc_1.1.1.bb         |  2 +
 2 files changed, 47 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-posix-ipc/0001-Use-default-cc-from-environment-variable.patch

diff --git a/meta-python/recipes-devtools/python/python3-posix-ipc/0001-Use-default-cc-from-environment-variable.patch b/meta-python/recipes-devtools/python/python3-posix-ipc/0001-Use-default-cc-from-environment-variable.patch
new file mode 100644
index 000000000..86829869a
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-posix-ipc/0001-Use-default-cc-from-environment-variable.patch
@@ -0,0 +1,45 @@
+From 2db4d9974052e28f25252b3204a73dd25de1dd89 Mon Sep 17 00:00:00 2001
+From: Gyorgy Sarvari <skandigraun@gmail.com>
+Date: Sat, 25 Jan 2025 13:09:00 +0100
+Subject: [PATCH] Use default cc from environment variable
+
+In case the system uses a custom c compiler instead of cc
+(e.g. for cross-compiling), probing system features can
+fail or can misidentify the features due to the incorrect C compiler.
+
+Instead of using only "cc" for probing features, check if the CC environment
+variable has a custom C compiler set. If it is present, use that instead of
+"cc". If it is not present, fall back to "cc".
+
+Upstream-Status: Submitted [https://github.com/osvenskan/posix_ipc/pull/56]
+---
+ prober.py | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/prober.py b/prober.py
+index 48432b7..ace6d3b 100644
+--- a/prober.py
++++ b/prober.py
+@@ -52,14 +52,17 @@ def print_bad_news(value_name, default):
+ def does_build_succeed(filename, linker_options=""):
+     # Utility function that returns True if the file compiles and links
+     # successfully, False otherwise.
+-    # Two things to note here --
++    # Three things to note here --
+     #   - If there's a linker option like -lrt, it needs to come *after*
+     #     the specification of the C file or linking will fail on Ubuntu 11.10
+     #     (maybe because of the gcc version?)
+     #   - Some versions of Linux place the sem_xxx() functions in libpthread.
+     #     Rather than testing whether or not it's needed, I just specify it
+     #     everywhere since it's harmless to specify it when it's not needed.
+-    cmd = "cc -Wall -o ./prober/foo ./prober/%s %s -lpthread" % (filename, linker_options)
++    #   - In case the used C compiler is not cc, take it from the CC environment
++    #     variable
++    cc = os.getenv("CC", "cc")
++    cmd = "%s -Wall -o ./prober/foo ./prober/%s %s -lpthread" % (cc, filename, linker_options)
+ 
+     p = subprocess.Popen(cmd, shell=True, stdout=STDOUT, stderr=STDERR)
+ 
+-- 
+2.48.1
+
diff --git a/meta-python/recipes-devtools/python/python3-posix-ipc_1.1.1.bb b/meta-python/recipes-devtools/python/python3-posix-ipc_1.1.1.bb
index 7106e9c5e..8fcf83b06 100644
--- a/meta-python/recipes-devtools/python/python3-posix-ipc_1.1.1.bb
+++ b/meta-python/recipes-devtools/python/python3-posix-ipc_1.1.1.bb
@@ -9,4 +9,6 @@ UPSTREAM_CHECK_PYPI_PACKAGE = "${PYPI_PACKAGE}"
 
 SRC_URI[sha256sum] = "e2456ba0cfb2ee5ba14121450e8d825b3c4a1461fca0761220aab66d4111cbb7"
 
+SRC_URI += "file://0001-Use-default-cc-from-environment-variable.patch"
+
 inherit setuptools3 pypi
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-25 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-25 12:44 [meta-python][PATCH] python3-posix-ipc: use correct C compiler to detect system features Gyorgy Sarvari
2025-01-25 15:08 ` Guðni Már Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.