aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3/Use-correct-CFLAGS-for-extensions-when-cross-compili.patch
blob: bf239c62619c423c01f3eb6f6251c90097de8662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 0fd8b986888ddf1995b503edf46ac827e83114d9 Mon Sep 17 00:00:00 2001
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Date: Wed, 23 Nov 2016 16:08:04 +0200
Subject: [PATCH] Use correct CFLAGS for extensions when cross-compiling

Take PY_CFLAGS_NODIST into account, like in native build. This is needed
in order to to profile-optimized build. Also, pass EXTRA_CFLAGS to
profile-optimized build.

Upstream-Status: Pending

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
 Makefile.pre.in | 4 ++--
 setup.py        | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.pre.in b/Makefile.pre.in
index bace00e..9635aa4 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -509,7 +509,7 @@ profile-opt:
 	$(MAKE) profile-removal
 
 build_all_generate_profile:
-	$(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
+	$(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(EXTRA_CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
 
 run_profile_task:
 	: # FIXME: can't run for a cross build
@@ -519,7 +519,7 @@ build_all_merge_profile:
 	$(LLVM_PROF_MERGER)
 
 build_all_use_profile:
-	$(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
+	$(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(EXTRA_CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
 
 # Compile and run with gcov
 .PHONY=coverage coverage-lcov coverage-report
diff --git a/setup.py b/setup.py
index c1ce87e..72d37cf 100644
--- a/setup.py
+++ b/setup.py
@@ -271,7 +271,8 @@ class PyBuildExt(build_ext):
         # compilers
         if compiler is not None:
             if cross_compiling:
-                (ccshared,cflags) = (os.environ.get('CCSHARED') or '', os.environ.get('CFLAGS') or '')
+                (ccshared,cflags) = (os.environ.get('CCSHARED') or '',
+                                     (os.environ.get('CFLAGS') or '') + ' ' + sysconfig.get_config_var('PY_CFLAGS_NODIST'))
             else:
                 (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
             args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
-- 
2.6.6