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

Cross compile openssl3.0 #18547

Closed
XYQ202 opened this issue Jun 14, 2022 · 9 comments
Closed

Cross compile openssl3.0 #18547

XYQ202 opened this issue Jun 14, 2022 · 9 comments
Labels
resolved: answered The issue contained a question which has been answered triaged: question The issue contains a question

Comments

@XYQ202
Copy link

XYQ202 commented Jun 14, 2022

hello openssl team,
I have been researching the functions of openssl-cmp these days, but the openssl-cmp function was introduced in openssl 3.0, so I need to cross-compile and port it to the ARM platform, but there are some problems during the compilation process:
1.With a 64-bit cross compiler (such as aarch64-linux-gnu-gcc), it can be compiled successfully and can be used normally after porting to the ARM platform。
2. But when I use a 32-bit cross compiler (such as arm-xilinx-linux-gnueabi-gcc), it cannot be compiled. The 32-bit cross compiler can compile the openssl1.0 version, but the openssl1.0 version does not have openssl-cmp function, so why is there such a bug?
Cross compilation process:
1. ./config no-asm --prefix=/usr/local/openssl
2. After the configuration is complete, modify the cross_compile item in the makefile, add the absolute path of the cross compiler,
3. make && sudo make install
But during compilation, the following error occurs:

crypto/bn/bn_dh.c:998:5: error: initializer element is not constant
crypto/bn/bn_dh.c:998:5: error: (near initialization for 'ffdhe8192_q[120]')
crypto/bn/bn_dh.c:998:5: warning: left shift count >= width of type
crypto/bn/bn_dh.c:998:5: error: initializer element is not constant
crypto/bn/bn_dh.c:998:5: error: (near initialization for 'ffdhe8192_q[121]')
crypto/bn/bn_dh.c:999:5: warning: left shift count >= width of type
BN_DEF(0x124D9F7C, 0xE649CEE7), BN_DEF(0x8A3219FD, 0xD4F09B20),
^
crypto/bn/bn_dh.c:999:5: error: initializer element is not constant
crypto/bn/bn_dh.c:999:5: error: (near initialization for 'ffdhe8192_q[122]')
crypto/bn/bn_dh.c:999:5: warning: left shift count >= width of type
crypto/bn/bn_dh.c:999:5: error: initializer element is not constant
crypto/bn/bn_dh.c:999:5: error: (near initialization for 'ffdhe8192_q[123]')
crypto/bn/bn_dh.c:1000:5: warning: left shift count >= width of type
BN_DEF(0xE7169B4A, 0xEC5CE2C1), BN_DEF(0x139E9E78, 0x57EE2B10),
^
crypto/bn/bn_dh.c:1000:5: error: initializer element is not constant
crypto/bn/bn_dh.c:1000:5: error: (near initialization for 'ffdhe8192_q[124]')
crypto/bn/bn_dh.c:1000:5: warning: left shift count >= width of type
crypto/bn/bn_dh.c:1000:5: error: initializer element is not constant
crypto/bn/bn_dh.c:1000:5: error: (near initialization for 'ffdhe8192_q[125]')
crypto/bn/bn_dh.c:1001:5: warning: left shift count >= width of type
BN_DEF(0x515DA54D, 0xD6FC2A2C), BN_DEF(0xFFFFFFFF, 0x7FFFFFFF),
^
crypto/bn/bn_dh.c:1001:5: error: initializer element is not constant
crypto/bn/bn_dh.c:1001:5: error: (near initialization for 'ffdhe8192_q[126]')
crypto/bn/bn_dh.c:1001:5: warning: left shift count >= width of type
crypto/bn/bn_dh.c:1001:5: error: initializer element is not constant
crypto/bn/bn_dh.c:1001:5: error: (near initialization for 'ffdhe8192_q[127]')
Makefile:13576: recipe for target 'crypto/bn/libcrypto-lib-bn_dh.o' failed
make[1]: *** [crypto/bn/libcrypto-lib-bn_dh.o] Error 1
make[1]: Leaving directory '/home/xyq/openssl/openssl-3.0.3'
Makefile:3213: recipe for target 'build_sw' failed
make: *** [build_sw] Error 2

32位交叉编译器编译都是crypto/bn/bn_dh.c文件中报错,这里只是截了一小段。这个如何解决呢,难道不能够32位和64位兼容嘛?

@XYQ202 XYQ202 added the issue: bug report The issue was opened to report a bug label Jun 14, 2022
@t8m t8m added triaged: question The issue contains a question and removed issue: bug report The issue was opened to report a bug labels Jun 14, 2022
@t8m
Copy link
Member

t8m commented Jun 14, 2022

IMO you have misconfigured the build. This is not the way to cross-compile. Please see the INSTALL.md and the Cross Compile Prefix section. You also need to explicitly set the target because config most probably won't be able to guess it correctly for you if you're cross-compiling.

@t8m t8m added the resolved: answered The issue contained a question which has been answered label Jun 14, 2022
@XYQ202
Copy link
Author

XYQ202 commented Jun 14, 2022

1 ./Configure linux-armv4 --cross-compile-prefix=arm-himix200-linux- --prefix=/data/work/openssl_instasll && make && make install
2. make && sudo make install
thanks

@XYQ202
Copy link
Author

XYQ202 commented Jun 14, 2022

However, on the ARM platform, executing openssl genrsa -out 1.pem to generate an RSA key pair will still report an error. I don't know why.

error:
genrsa: Error generating RSA key

@XYQ202
Copy link
Author

XYQ202 commented Jun 15, 2022

you have misconfigured the build. This is not the way to cross-compile. Please see the INSTALL.md and the Cross Compile Prefix section. You also need to explicitly set the target because config most probably won't be able to guess it correctly for you if you're cross-compiling.

thanks,It can be compiled and passed, but it will report an error when running。

@t8m
Copy link
Member

t8m commented Jun 15, 2022

Is the target system linux? What happens if you configure with no-asm?

@t8m
Copy link
Member

t8m commented Jun 15, 2022

What happens if you strace the openssl genrsa command? Do you see anything suspicious in regards to the kernel rng?

@t8m
Copy link
Member

t8m commented Jun 15, 2022

The genrsa problem is now in #18569

@t8m t8m closed this as completed Jun 15, 2022
@XYQ202
Copy link
Author

XYQ202 commented Jun 15, 2022

Is the target system linux? What happens if you configure with no-asm?

Yes, I have tried many methods, but I still cannot generate an RSA private key。
my kernel doesn't have the tarce command。

@muyuanjin999
Copy link

hello openssl team, I have been researching the functions of openssl-cmp these days, but the openssl-cmp function was introduced in openssl 3.0, so I need to cross-compile and port it to the ARM platform, but there are some problems during the compilation process: 1.With a 64-bit cross compiler (such as aarch64-linux-gnu-gcc), it can be compiled successfully and can be used normally after porting to the ARM platform。 2. But when I use a 32-bit cross compiler (such as arm-xilinx-linux-gnueabi-gcc), it cannot be compiled. The 32-bit cross compiler can compile the openssl1.0 version, but the openssl1.0 version does not have openssl-cmp function, so why is there such a bug? Cross compilation process: 1. ./config no-asm --prefix=/usr/local/openssl 2. After the configuration is complete, modify the cross_compile item in the makefile, add the absolute path of the cross compiler, 3. make && sudo make install But during compilation, the following error occurs:

crypto/bn/bn_dh.c:998:5: error: initializer element is not constant crypto/bn/bn_dh.c:998:5: error: (near initialization for 'ffdhe8192_q[120]') crypto/bn/bn_dh.c:998:5: warning: left shift count >= width of type crypto/bn/bn_dh.c:998:5: error: initializer element is not constant crypto/bn/bn_dh.c:998:5: error: (near initialization for 'ffdhe8192_q[121]') crypto/bn/bn_dh.c:999:5: warning: left shift count >= width of type BN_DEF(0x124D9F7C, 0xE649CEE7), BN_DEF(0x8A3219FD, 0xD4F09B20), ^ crypto/bn/bn_dh.c:999:5: error: initializer element is not constant crypto/bn/bn_dh.c:999:5: error: (near initialization for 'ffdhe8192_q[122]') crypto/bn/bn_dh.c:999:5: warning: left shift count >= width of type crypto/bn/bn_dh.c:999:5: error: initializer element is not constant crypto/bn/bn_dh.c:999:5: error: (near initialization for 'ffdhe8192_q[123]') crypto/bn/bn_dh.c:1000:5: warning: left shift count >= width of type BN_DEF(0xE7169B4A, 0xEC5CE2C1), BN_DEF(0x139E9E78, 0x57EE2B10), ^ crypto/bn/bn_dh.c:1000:5: error: initializer element is not constant crypto/bn/bn_dh.c:1000:5: error: (near initialization for 'ffdhe8192_q[124]') crypto/bn/bn_dh.c:1000:5: warning: left shift count >= width of type crypto/bn/bn_dh.c:1000:5: error: initializer element is not constant crypto/bn/bn_dh.c:1000:5: error: (near initialization for 'ffdhe8192_q[125]') crypto/bn/bn_dh.c:1001:5: warning: left shift count >= width of type BN_DEF(0x515DA54D, 0xD6FC2A2C), BN_DEF(0xFFFFFFFF, 0x7FFFFFFF), ^ crypto/bn/bn_dh.c:1001:5: error: initializer element is not constant crypto/bn/bn_dh.c:1001:5: error: (near initialization for 'ffdhe8192_q[126]') crypto/bn/bn_dh.c:1001:5: warning: left shift count >= width of type crypto/bn/bn_dh.c:1001:5: error: initializer element is not constant crypto/bn/bn_dh.c:1001:5: error: (near initialization for 'ffdhe8192_q[127]') Makefile:13576: recipe for target 'crypto/bn/libcrypto-lib-bn_dh.o' failed make[1]: *** [crypto/bn/libcrypto-lib-bn_dh.o] Error 1 make[1]: Leaving directory '/home/xyq/openssl/openssl-3.0.3' Makefile:3213: recipe for target 'build_sw' failed make: *** [build_sw] Error 2

32位交叉编译器编译都是crypto/bn/bn_dh.c文件中报错,这里只是截了一小段。这个如何解决呢,难道不能够32位和64位兼容嘛?
大佬,怎么用aarch64-linux-gnu-gcc编译啊?我报错openssl/opensslconf.h: No such file or directory,需要安装openssl是吗?我想手动编译安装openssl到交叉编译库文件夹 ./Configure --prefix=/usr/${CROSS} os/compiler:${CC},但是并没有运行成功,是哪里出错了吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved: answered The issue contained a question which has been answered triaged: question The issue contains a question
Projects
None yet
Development

No branches or pull requests

3 participants