Build cst 3.3.1 built with libcrypto static library

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Build cst 3.3.1 built with libcrypto static library

Jump to solution
3,091 Views
gonzalo_ruiz
Contributor II

Hi team,

We are currently building cst 3.3.1 for a linux 64b machine using the following command:

make -j8 OSTYPE=linux64 rel_bin

As a result we get both srktool and cst binaries linking to the libcrypto shared library, which makes it mandatory for any other machine we deploy these artifacts to to have the same shared library.

~/cst-3.3.1/code/cst$ ldd release/linux64/bin/cst
linux-vdso.so.1 => (0x00007ffe19fea000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007f4f803d8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4f8000e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4f7fe0a000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4f8081d000)

We noticed the precompiled srktool and cst binaries under path linux64/bin do not link to that shared library, and have a bigger size instead, so we guess the libcrypto library was linked as static in these artifacts:

~/cst-3.3.1$ ldd linux64/bin/cst
linux-vdso.so.1 => (0x00007ffcc4809000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8baceee000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8bad2b8000)

We are interested into reproducing similar binaries and we would like to know what is the command (or the changes) that was used to create this artifacts with the static library.

My machine is an Ubuntu 16.04 with OpenSSL 1.0.2g 1 Mar 2016.


Thanks,

Gonzalo

0 Kudos
Reply
1 Solution
3,004 Views
IvanRuiz
NXP Employee
NXP Employee

Hello,

 

I think libcrypto.a need to be rebuilt because I noticed OPENSSL_CONFIG in cst-3.3.1/code/cst/Makefile
According to CST_UG.pdf, cst-3.3.1 is built using OpenSSL 1.1.1.
The following are the steps we followed:

1, Download OpenSSL from https://www.openssl.org/source/old/1.1.1/. Decompress into cst-3.3.1/code/ and rename to "openssl"
2, modify cst-3.3.1/code/cst/code/build/make/gcc.mk

@@ -22,13 +22,13 @@ OBJCOPY := objcopy

 # C compiler flags
 #==============================================================================
-COPTIONS += -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Werror -pedantic -fPIC -g
+COPTIONS += -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Werror -pedantic -fPIC -g -I../openssl/include

 # Linker flags
 #==============================================================================
 LDOPTIONS += -g

-LDLIBS := -lcrypto
+LDLIBS := -l:../openssl/libcrypto.a

 # Archiver flags
 #==============================================================================

3, cd cst-3.3.1/code/cst
4, make -j8 OSTYPE=linux64 openssl
5, make -j8 OSTYPE=linux64 clean
6, make -j8 OSTYPE=linux64 rel_bin

 

Hope it helps!

 

BR,

Ivan.

View solution in original post

0 Kudos
Reply
3 Replies
3,030 Views
IvanRuiz
NXP Employee
NXP Employee

Hi Gonzalo,

 

Which i.MX product is this question related to?

 

Thank you.

 

BR,

Ivan

0 Kudos
Reply
3,022 Views
gonzalo_ruiz
Contributor II

Hi Ivan,

The question affects a bunch of our products based on: i.MX6, i.MX6UL, i.MX8X and i.MX8MNano.

I was able to statically link the libcrypto library with this change:

diff --git a/code/cst/code/build/make/gcc.mk b/code/cst/code/build/make/gcc.mk
index 0394f5a..cc57f6b 100755
--- a/code/cst/code/build/make/gcc.mk
+++ b/code/cst/code/build/make/gcc.mk
@@ -28,7 +28,7 @@ COPTIONS += -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Werror -pedantic -fPIC -g
#==============================================================================
LDOPTIONS += -g

-LDLIBS := -lcrypto
+LDLIBS := -Wl,-Bstatic -lcrypto -Wl,-Bdynamic -lpthread -ldl

# Archiver flags
#==============================================================================

But I was forced to link to the libpthread and libdl shared libraries in my host machine.

Is there a better way to achieve binaries similar to the ones provided by default?

 

Regards,

Gonzalo

0 Kudos
Reply
3,005 Views
IvanRuiz
NXP Employee
NXP Employee

Hello,

 

I think libcrypto.a need to be rebuilt because I noticed OPENSSL_CONFIG in cst-3.3.1/code/cst/Makefile
According to CST_UG.pdf, cst-3.3.1 is built using OpenSSL 1.1.1.
The following are the steps we followed:

1, Download OpenSSL from https://www.openssl.org/source/old/1.1.1/. Decompress into cst-3.3.1/code/ and rename to "openssl"
2, modify cst-3.3.1/code/cst/code/build/make/gcc.mk

@@ -22,13 +22,13 @@ OBJCOPY := objcopy

 # C compiler flags
 #==============================================================================
-COPTIONS += -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Werror -pedantic -fPIC -g
+COPTIONS += -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Werror -pedantic -fPIC -g -I../openssl/include

 # Linker flags
 #==============================================================================
 LDOPTIONS += -g

-LDLIBS := -lcrypto
+LDLIBS := -l:../openssl/libcrypto.a

 # Archiver flags
 #==============================================================================

3, cd cst-3.3.1/code/cst
4, make -j8 OSTYPE=linux64 openssl
5, make -j8 OSTYPE=linux64 clean
6, make -j8 OSTYPE=linux64 rel_bin

 

Hope it helps!

 

BR,

Ivan.

0 Kudos
Reply