Skip to content
This repository was archived by the owner on Feb 24, 2023. It is now read-only.

Commit 26161e9

Browse files
committed
Move -gcc-toolchain and -target back to CPPLAGS and LDFLAGS
Now CPython's distutils supports that well!
1 parent 65e8dc3 commit 26161e9

File tree

7 files changed

+304
-115
lines changed

7 files changed

+304
-115
lines changed

mk/openssl/fix-cflags.patch

Lines changed: 0 additions & 60 deletions
This file was deleted.

mk/openssl/ndk-clang-targets.patch

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
2+
index 59234a8a5..68b83af34 100644
3+
--- a/Configurations/10-main.conf
4+
+++ b/Configurations/10-main.conf
5+
@@ -878,97 +878,6 @@ sub vms_info {
6+
ranlib => "true",
7+
},
8+
9+
-#### Android: linux-* but without pointers to headers and libs.
10+
- #
11+
- # It takes pair of prior-set environment variables to make it work:
12+
- #
13+
- # CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<arch>
14+
- # CROSS_COMPILE=<prefix>
15+
- #
16+
- # As well as PATH adjusted to cover ${CROSS_COMPILE}gcc and company.
17+
- # For example to compile for ICS and ARM with NDK 10d, you'd:
18+
- #
19+
- # ANDROID_NDK=/some/where/android-ndk-10d
20+
- # CROSS_SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
21+
- # CROSS_COMPILE=arm-linux-adroideabi-
22+
- # PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/bin
23+
- #
24+
- "android" => {
25+
- inherit_from => [ "linux-generic32" ],
26+
- # Special note about unconditional -fPIC and -pie. The underlying
27+
- # reason is that Lollipop refuses to run non-PIE. But what about
28+
- # older systems and NDKs? -fPIC was never problem, so the only
29+
- # concern is -pie. Older toolchains, e.g. r4, appear to handle it
30+
- # and binaries turn mostly functional. "Mostly" means that oldest
31+
- # Androids, such as Froyo, fail to handle executable, but newer
32+
- # systems are perfectly capable of executing binaries targeting
33+
- # Froyo. Keep in mind that in the nutshell Android builds are
34+
- # about JNI, i.e. shared libraries, not applications.
35+
- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
36+
- bin_cflags => "-pie",
37+
- },
38+
- "android-x86" => {
39+
- inherit_from => [ "android", asm("x86_asm") ],
40+
- cflags => add(picker(release => "-fomit-frame-pointer")),
41+
- bn_ops => "BN_LLONG",
42+
- perlasm_scheme => "android",
43+
- },
44+
- ################################################################
45+
- # Contemporary Android applications can provide multiple JNI
46+
- # providers in .apk, targeting multiple architectures. Among
47+
- # them there is "place" for two ARM flavours: generic eabi and
48+
- # armv7-a/hard-float. However, it should be noted that OpenSSL's
49+
- # ability to engage NEON is not constrained by ABI choice, nor
50+
- # is your ability to call OpenSSL from your application code
51+
- # compiled with floating-point ABI other than default 'soft'.
52+
- # [Latter thanks to __attribute__((pcs("aapcs"))) declaration.]
53+
- # This means that choice of ARM libraries you provide in .apk
54+
- # is driven by application needs. For example if application
55+
- # itself benefits from NEON or is floating-point intensive, then
56+
- # it might be appropriate to provide both libraries. Otherwise
57+
- # just generic eabi would do. But in latter case it would be
58+
- # appropriate to
59+
- #
60+
- # ./Configure android-armeabi -D__ARM_MAX_ARCH__=8
61+
- #
62+
- # in order to build "universal" binary and allow OpenSSL take
63+
- # advantage of NEON when it's available.
64+
- #
65+
- "android-armeabi" => {
66+
- inherit_from => [ "android", asm("armv4_asm") ],
67+
- },
68+
- "android-mips" => {
69+
- inherit_from => [ "android", asm("mips32_asm") ],
70+
- perlasm_scheme => "o32",
71+
- },
72+
-
73+
- "android64" => {
74+
- inherit_from => [ "linux-generic64" ],
75+
- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
76+
- bin_cflags => "-pie",
77+
- },
78+
- "android64-aarch64" => {
79+
- inherit_from => [ "android64", asm("aarch64_asm") ],
80+
- perlasm_scheme => "linux64",
81+
- },
82+
- "android64-x86_64" => {
83+
- inherit_from => [ "android64", asm("x86_64_asm") ],
84+
- perlasm_scheme => "elf",
85+
- },
86+
- "android64-mips64" => {
87+
- ############################################################
88+
- # You are more than likely have to specify target processor
89+
- # on ./Configure command line. Trouble is that toolchain's
90+
- # default is MIPS64r6 (at least in r10d), but there are no
91+
- # such processors around (or they are too rare to spot one).
92+
- # Actual problem is that MIPS64r6 is binary incompatible
93+
- # with previous MIPS ISA versions, in sense that unlike
94+
- # prior versions original MIPS binary code will fail.
95+
- #
96+
- inherit_from => [ "android64", asm("mips64_asm") ],
97+
- perlasm_scheme => "64",
98+
- },
99+
-
100+
#### *BSD
101+
"BSD-generic32" => {
102+
# As for thread cflag. Idea is to maintain "collective" set of
103+
diff --git a/Configurations/20-android.conf b/Configurations/20-android.conf
104+
new file mode 100644
105+
index 000000000..ce11a5ae3
106+
--- /dev/null
107+
+++ b/Configurations/20-android.conf
108+
@@ -0,0 +1,171 @@
109+
+#### Android: linux-* but without pointers to headers and libs.
110+
+
111+
+%targets = (
112+
+ #
113+
+ # It takes pair of prior-set environment variables to make it work:
114+
+ #
115+
+ # CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<arch>
116+
+ # CROSS_COMPILE=<prefix>
117+
+ #
118+
+ # As well as PATH adjusted to cover ${CROSS_COMPILE}gcc and company.
119+
+ # For example to compile for ICS and ARM with NDK 10d, you'd:
120+
+ #
121+
+ # ANDROID_NDK=/some/where/android-ndk-10d
122+
+ # CROSS_SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
123+
+ # CROSS_COMPILE=arm-linux-adroideabi-
124+
+ # PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/bin
125+
+ #
126+
+ "android-base" => {
127+
+ inherit_from => [ "linux-generic32" ],
128+
+ template => 1,
129+
+ # Special note about unconditional -fPIC and -pie. The underlying
130+
+ # reason is that Lollipop refuses to run non-PIE. But what about
131+
+ # older systems and NDKs? -fPIC was never problem, so the only
132+
+ # concern is -pie. Older toolchains, e.g. r4, appear to handle it
133+
+ # and binaries turn mostly functional. "Mostly" means that oldest
134+
+ # Androids, such as Froyo, fail to handle executable, but newer
135+
+ # systems are perfectly capable of executing binaries targeting
136+
+ # Froyo. Keep in mind that in the nutshell Android builds are
137+
+ # about JNI, i.e. shared libraries, not applications.
138+
+ cflags => add(picker(default => "-fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
139+
+ bin_cflags => "-pie",
140+
+ },
141+
+ "android-x86-base" => {
142+
+ inherit_from => [ asm("x86_asm") ],
143+
+ template => 1,
144+
+ cflags => add(picker(release => "-fomit-frame-pointer")),
145+
+ bn_ops => "BN_LLONG",
146+
+ perlasm_scheme => "android",
147+
+ },
148+
+ ################################################################
149+
+ # Contemporary Android applications can provide multiple JNI
150+
+ # providers in .apk, targeting multiple architectures. Among
151+
+ # them there is "place" for two ARM flavours: generic eabi and
152+
+ # armv7-a/hard-float. However, it should be noted that OpenSSL's
153+
+ # ability to engage NEON is not constrained by ABI choice, nor
154+
+ # is your ability to call OpenSSL from your application code
155+
+ # compiled with floating-point ABI other than default 'soft'.
156+
+ # [Latter thanks to __attribute__((pcs("aapcs"))) declaration.]
157+
+ # This means that choice of ARM libraries you provide in .apk
158+
+ # is driven by application needs. For example if application
159+
+ # itself benefits from NEON or is floating-point intensive, then
160+
+ # it might be appropriate to provide both libraries. Otherwise
161+
+ # just generic eabi would do. But in latter case it would be
162+
+ # appropriate to
163+
+ #
164+
+ # ./Configure android-armeabi -D__ARM_MAX_ARCH__=8
165+
+ #
166+
+ # in order to build "universal" binary and allow OpenSSL take
167+
+ # advantage of NEON when it's available.
168+
+ #
169+
+ "android-armeabi-base" => {
170+
+ inherit_from => [ asm("armv4_asm") ],
171+
+ template => 1,
172+
+ },
173+
+ "android-mips-base" => {
174+
+ inherit_from => [ asm("mips32_asm") ],
175+
+ template => 1,
176+
+ perlasm_scheme => "o32",
177+
+ },
178+
+
179+
+ "android64-base" => {
180+
+ inherit_from => [ "linux-generic64" ],
181+
+ template => 1,
182+
+ cflags => add(picker(default => "-fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
183+
+ bin_cflags => "-pie",
184+
+ },
185+
+ "android64-aarch64-base" => {
186+
+ inherit_from => [ asm("aarch64_asm") ],
187+
+ template => 1,
188+
+ perlasm_scheme => "linux64",
189+
+ },
190+
+ "android64-x86_64-base" => {
191+
+ inherit_from => [ asm("x86_64_asm") ],
192+
+ template => 1,
193+
+ perlasm_scheme => "elf",
194+
+ },
195+
+ "android64-mips64-base" => {
196+
+ ############################################################
197+
+ # You are more than likely have to specify target processor
198+
+ # on ./Configure command line. Trouble is that toolchain's
199+
+ # default is MIPS64r6 (at least in r10d), but there are no
200+
+ # such processors around (or they are too rare to spot one).
201+
+ # Actual problem is that MIPS64r6 is binary incompatible
202+
+ # with previous MIPS ISA versions, in sense that unlike
203+
+ # prior versions original MIPS binary code will fail.
204+
+ #
205+
+ inherit_from => [ asm("mips64_asm") ],
206+
+ template => 1,
207+
+ perlasm_scheme => "64",
208+
+ },
209+
+
210+
+ # GCC targets
211+
+ "android" => {
212+
+ inherit_from => [ "android-base" ],
213+
+ cflags => add(picker(default => "-mandroid")),
214+
+ },
215+
+ "android-x86" => {
216+
+ inherit_from => [ "android", "android-x86-base" ],
217+
+ },
218+
+ "android-armeabi" => {
219+
+ inherit_from => [ "android", "android-armeabi-base" ],
220+
+ },
221+
+ "android-mips" => {
222+
+ inherit_from => [ "android", "android-mips-base" ],
223+
+ },
224+
+ "android64" => {
225+
+ inherit_from => [ "android64-base" ],
226+
+ cflags => add(picker(default => "-mandroid")),
227+
+ },
228+
+ "android64-aarch64" => {
229+
+ inherit_from => [ "android64", "android64-aarch64-base" ],
230+
+ },
231+
+ "android64-x86_64" => {
232+
+ inherit_from => [ "android64", "android64-x86_64-base" ],
233+
+ },
234+
+ "android64-mips64" => {
235+
+ inherit_from => [ "android64", "android64-mips64-base" ],
236+
+ },
237+
+
238+
+ # Clang targets
239+
+ "android-clang" => {
240+
+ inherit_from => [ "android-base" ],
241+
+ cc => "clang",
242+
+ cxx => "clang++",
243+
+ cflags => add(picker(default => "-gcc-toolchain \$(GCC_TOOLCHAIN) -D__ANDROID_API__=\$(ANDROID_API_LEVEL)")),
244+
+ bin_cflags => add(picker(default => "--sysroot=\$(ARCH_SYSROOT)")),
245+
+ shared_ldflag => add(picker(default => "-pie --sysroot=\$(ARCH_SYSROOT)")),
246+
+ },
247+
+ "android-x86-clang" => {
248+
+ inherit_from => [ "android-clang", "android-x86-base" ],
249+
+ cflags => add(picker(default => "-target i686-none-linux-android -I\$(CROSS_SYSROOT)/include/i686-linux-android -fno-integrated-as")),
250+
+ },
251+
+ "android-armeabi-clang" => {
252+
+ inherit_from => [ "android-clang", "android-armeabi-base" ],
253+
+ cflags => add(picker(default => "-target armv7-none-linux-androideabi -I\$(CROSS_SYSROOT)/include/arm-linux-androideabi -fno-integrated-as")),
254+
+ },
255+
+ "android-mips-clang" => {
256+
+ inherit_from => [ "android-clang", "android-mips-base" ],
257+
+ cflags => add(picker(default => "-target mipsel-none-linux-android -I\$(CROSS_SYSROOT)/include/mipsel-linux-android -fno-integrated-as")),
258+
+ },
259+
+ "android64-clang" => {
260+
+ inherit_from => [ "android64-base" ],
261+
+ cc => "clang",
262+
+ cxx => "clang++",
263+
+ cflags => add(picker(default => "-gcc-toolchain \$(GCC_TOOLCHAIN) -D__ANDROID_API__=\$(ANDROID_API_LEVEL)")),
264+
+ bin_cflags => add(picker(default => "--sysroot=\$(ARCH_SYSROOT)")),
265+
+ shared_ldflag => add(picker(default => "-pie --sysroot=\$(ARCH_SYSROOT)")),
266+
+ },
267+
+ "android64-aarch64-clang" => {
268+
+ inherit_from => [ "android64-clang", "android64-aarch64-base" ],
269+
+ cflags => add(picker(default => "-target aarch64-none-linux-android -I\$(CROSS_SYSROOT)/include/aarch64-linux-android -fno-integrated-as")),
270+
+ },
271+
+ "android64-x86_64-clang" => {
272+
+ inherit_from => [ "android64-clang", "android64-x86_64-base" ],
273+
+ cflags => add(picker(default => "-target x86_64-none-linux-android -I\$(CROSS_SYSROOT)/include/x86_64-linux-android")),
274+
+ },
275+
+ "android64-mips64-clang" => {
276+
+ inherit_from => [ "android64-clang", "android64-mips64-base" ],
277+
+ cflags => add(picker(default => "-target mips64el-none-linux-android -I\$(CROSS_SYSROOT)/include/mips64el-linux-android")),
278+
+ },
279+
+);

0 commit comments

Comments
 (0)