Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenSSL] "Unsupported options: no-canonical-prefixes" #7

Open
Linux13524 opened this issue Feb 16, 2019 · 13 comments
Open

[OpenSSL] "Unsupported options: no-canonical-prefixes" #7

Linux13524 opened this issue Feb 16, 2019 · 13 comments

Comments

@Linux13524
Copy link

Description of Problem, Request, or Question

I am trying to build OpenSSL with this profile:

[settings]
os=Android
arch=armv7
os.api_level=21
compiler=clang
compiler.libcxx=libc++
compiler.version=7.0
build_type=Release
os_build=Linux
arch_build=x86_64

[build_requires]
android-ndk/r18@theodelrieu/testing

The command ./Configure android-armeabi -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sources/cxx-stl/llvm-libc++abi/include -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sources/cxx-stl/llvm-libc++/include -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sysroot/usr/include/arm-linux-androideabi --target=arm-none-linux-androideabi21 --sysroot=/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sysroot -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes --gcc-toolchain=/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -mfpu=neon -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -DNDEBUG -Oz -Wformat -Werror=format-security -Werror=implicit-function-declaration -O3 -fPIC --with-zlib-include="/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/include" --with-zlib-lib="/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/lib" results in the following error:

Failure!  build file wasn't produced.
Please read INSTALL and associated NOTES files.  You may also have to look over
your available compiler tool chain or change your configuration.

***** Unsupported options: no-canonical-prefixes

Related issue: openssl/openssl#3493

Package Details (Include if Applicable)

  • Package Name/Version: OpenSSL/1.1.1a
  • Operating System: Linux
  • Operation System Version: Fedora 29
  • Compiler+version: clang 7.0 (Android NDK)
  • Conan version: conan 1.11.2
  • Python version: python 3.7.2

Steps to reproduce (Include if Applicable)

  1. Clone recipe:
git clone https://github.com/conan-community/conan-openssl.git
cd conan-openssl
  1. Create package:
conan create . linux13524/testing -pr android_21_armeabi-v7a_clang -b missing

To see the actual error message, I had to run the ./Configure command manually...

@theodelrieu
Copy link
Owner

Hello, I remember facing this issue. I will be able to work on it Monday though.

Thanks for the report.

@Linux13524
Copy link
Author

Linux13524 commented Feb 17, 2019

Do you know, why is the error not written to console by conan? I just get:

[...]
OpenSSL/1.1.1a@linux13524/testing: Calling build()
OpenSSL/1.1.1a@linux13524/testing: =====> Options:  --with-zlib-include="/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/include" --with-zlib-lib="/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/lib"
OpenSSL/1.1.1a@linux13524/testing: ------RUNNING-------
bash -l -c -o pipefail "./Configure android-arm -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sources/cxx-stl/llvm-libc++abi/include -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sources/cxx-stl/llvm-libc++/include -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sysroot/usr/include/arm-linux-androideabi --target=arm-none-linux-androideabi21 --sysroot=/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sysroot -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes --gcc-toolchain=/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -mfpu=neon -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -DNDEBUG -Oz -Wformat -Werror=format-security -Werror=implicit-function-declaration -O3 -fPIC --with-zlib-include=\"/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/include\" --with-zlib-lib=\"/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/lib\" | while read line; do printf \"%c\" .; done"OpenSSL/1.1.1a@linux13524/testing: 
OpenSSL/1.1.1a@linux13524/testing: ERROR: Package '534df50dac7c680f5f1cff0af81b32be7b5b5a24' build failed
OpenSSL/1.1.1a@linux13524/testing: WARN: Build folder /home/lk/.conan/data/OpenSSL/1.1.1a/linux13524/testing/build/534df50dac7c680f5f1cff0af81b32be7b5b5a24
ERROR: OpenSSL/1.1.1a@linux13524/testing: Error in build() method, line 83
	self.unix_build()
while calling 'unix_build', line 216
	self.run_in_src("./Configure %s %s" % (target, self._get_flags()), win_bash=win_bash)
while calling 'run_in_src', line 103
	self.run(command, win_bash=win_bash, output=buf)
	ConanException: Error 255 while executing bash -l -c -o pipefail "./Configure android-arm -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sources/cxx-stl/llvm-libc++abi/include -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sources/cxx-stl/llvm-libc++/include -isystem/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sysroot/usr/include/arm-linux-androideabi --target=arm-none-linux-androideabi21 --sysroot=/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sysroot -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes --gcc-toolchain=/home/lk/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -mfpu=neon -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -DNDEBUG -Oz -Wformat -Werror=format-security -Werror=implicit-function-declaration -O3 -fPIC --with-zlib-include=\"/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/include\" --with-zlib-lib=\"/home/lk/.conan/data/zlib/1.2.11/conan/stable/package/3fb95ed85ddddc32c8a68fbda3fc929cdd5c192b/lib\" | while read line; do printf \"%c\" .; done"

EDIT:
Found it: The OpenSSL recipe disables it for clang compiler in this line.

@theodelrieu
Copy link
Owner

Hello,

I remember why this happens, according to the OpenSSL wiki single hyphen flags (e.g. -no-canonical-prefixes) gets the hyphen removed and added to CFLAGS.

One workaround would be to hack the recipe and add a + before the hyphen. It should only discard the + and pass -no-canonical-prefixes to the compiler.

I'd like to have a more elegant/effective way of solving the issue though, I'd suggest opening an issue on the OpenSSL recipe repo referencing this one, to get their opinion on the way to go.

@maikelvdh
Copy link

Alternative route is to supply to configure CPPFLAGS, CFLAGS and LDFLAGS in case of OpenSSL then you won't get bothered by the fact that the hyphens will be dropped. This does mean you would need to adapt the OpenSSL Conan recipe to deal with this specifically.

That is what I did in our company to prevent running into multiple issues with supporting OpenSSL in combination with the android toolchain.

@Linux13524
Copy link
Author

I opened the issue..
So when removing -no-canonical-prefixes or adding a + to it I get an other error unrelated to this option:

$ANDROID_NDK is not defined at (eval 9) line 26

This env variable should be added to the android-ndk recipe, right?

@theodelrieu
Copy link
Owner

You can go hack your local recipe in ~/.conan/data/android-ndk/r18/theodelrieu/testing/export/conanfile.py without recreating the package everytime.

I have vague memories of this error, and setting ANDROID_NDK to the ndk root path uncovered a new error IIRC.

I hope @maikelvdh has the right patch for it 😅

@Linux13524
Copy link
Author

You can go hack your local recipe in ~/.conan/data/android-ndk/r18/theodelrieu/testing/export/conanfile.py without recreating the package everytime.

Good to know. Thanks!

I hope @maikelvdh has the right patch for it 😅

I hope so too..
The hack with the + does not work for me: +-no-canonical-prefixes is passed to clang resulting in an error: no such file or directory. Seems like the + is not removed while configuring..

@theodelrieu
Copy link
Owner

Hmm, I guess you have to try that then:

Alternative route is to supply to configure CPPFLAGS, CFLAGS and LDFLAGS in case of OpenSSL then you won't get bothered by the fact that the hyphens will be dropped.

@cajus
Copy link

cajus commented Mar 28, 2019

Hi! Just found this issue while trying to get the build for OpenSSL on Android running. @maikelvdh would you mind sharing what you changed in the OpenSSL reciepe to get it running?

I got it compiling after some time of tweaking, but now the linker claims that it can't find -ldl and -lc. For a static build. Gnaaaa.

@theodelrieu: just started with conan - before that, I used a make_standalone_toolchain.py generated toolchain for building OpenSSL. Maybe it can simplify things a bit?

@theodelrieu
Copy link
Owner

Hello, this is probably due to the double sysroots in NDK r18. They were unified in r19.

We are working with @SSE4 to overhaul this project by replacing it with this one, could you try with the testing/r19b branch?

We have still some tweaks to make but it should at least fix the linker error.

@cajus
Copy link

cajus commented Mar 28, 2019

Thanks @theodelrieu for the quick answer. Just tried with reverted changes to my local copy of the OpenSSL reciepe. It has similar problems as this repo.

Sadly the Configure script of OpenSSL is trying to detect everything needed to set CC, CFLAGS, etc. by itself, depending on what it finds in the PATH:

OpenSSL/1.1.1b@bje/stable: ------RUNNING-------
bash -l -c -o pipefail "./Configure android-arm -O3 --sysroot=/home/cajus/.conan/data/android_ndk_installer/r19b/bje/stable/package/84fc5086d5b84ea42507b9623275f83e74452fe1/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -D__ANDROID_API__=21 no-asm no-engine no-ssl3 no-weak-ssl-ciphers no-zlib | while read line; do printf \"%c\" .; done"
no NDK arm-linux-androideabi-gcc on $PATH at (eval 9) line 124.

Finally I managed to build OpenSSL using https://github.com/bincrafters/conan-android_ndk_installer/tree/testing/r19b with two little hacks in the OpenSSL reciepe:

@@ -219,11 +219,26 @@ class OpenSSLConan(ConanFile):
         if self.settings.os == "Android":
             makefile = os.path.join(self.subfolder, "Makefile")
 
+            old_str = 'CROSS_COMPILE='
+            new_str = 'DISABLED_CROSS_COMPILE='
+            tools.replace_in_file(makefile, old_str, new_str, strict=self.in_local_cache)
+
+            old_str = '-mandroid'
+            new_str = ''
+            tools.replace_in_file(makefile, old_str, new_str, strict=self.in_local_cache)
+
     def unix_build(self):
         win_bash = sys.platform == "win32"
         target = self._get_target()
 
+        if self.settings.os == "Android":
+            old_str = 'die "no NDK $triarch-gcc on \$PATH";'
+            new_str = '-install_name '
+            tools.replace_in_file("%s/Configurations/15-android.conf" % self.subfolder, old_str, new_str,
+                              strict=self.in_local_cache)
+
         self.run_in_src("./Configure %s %s" % (target, self._get_flags()), win_bash=win_bash)
         self.run_in_src("make depend")
 
         self._patch_makefile()

That's not nice, but seems to produce something that passes the tests. Thanks for your help!

@theodelrieu
Copy link
Owner

I think there is a way to provide CC to it, but we will have to figure that out. Glad to hear!

@Linux13524
Copy link
Author

I also tried with bincrafters android-ndk-installer (r19b), but with OpenSSL version 1.0.2r and it works fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants