Project

General

Profile

Trying to cross compile libsodium.

Added by Edwin McKay over 3 years ago

I am trying to compile the crypto library libsodium for use in the mitydsp. I created a project using the instructions for the starter c++ project. I am running into an issue with the assembly files. I believe that the contents of the file should be skipped, there is a #ifdef at the top of file; but it appears that the file is run through the assembler anyway. The define item is NOT defined, the only place the occurs in the project is at the top of the file.. it is as if the assembly does not recognize the #ifdef.

I can include more information if needed.


Replies (6)

RE: Trying to cross compile libsodium. - Added by Jonathan Cormier over 3 years ago

I'm not familiar with libsodium. Could you provide a link to the source your building? How you are trying to build it? The full build output attached in a text file. Anything else you think will be helpful.

Which toolchain are you using?

RE: Trying to cross compile libsodium. - Added by Edwin McKay over 3 years ago

https://github.com/jedisct1/libsodium/releases is the source location.

I created the CCS project as shown in the "startup" wiki for the MityDSP.
In C/C++ Build - Discovery Options - Cross G++ Compiler - Compiler invocation command I have "arm-angstrom-linux-gnueabi-g++"
In C/C++ Build - Discovery Options - Cross GCC Compiler - Compiler invocation command I have "arm-angstrom-linux-gnueabi-gcc"

In C/C++ Build - Environment - Path I have
/usr/local/oecore-i686/sysroots/i686-angstromsdk-linux/usr/bin/armv5te-angstrom-linux-gnueabi:/home/mitydsp/projects/u-boot-mitydspl138/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/ti/ccsv5/utils/bin:/opt/ti/ccsv5/tools/utils/bin:/opt/ti/ccsv5/ccs_base/emulation/analysis/bin/.:/opt/ti/ccsv5/ccs_base/emulation/analysis/bin/../xmldb/aet_config:/opt/ti/ccsv5/ccs_base/emulation/analysis/bin/../xmldb/trace_config/setup:/opt/ti/ccsv5/ccs_base/emulation/analysis/bin/../xmldb/trace_config/devices:/opt/ti/ccsv5/ccs_base/emulation/analysis/bin/../../../common/bin:/opt/ti/ccsv5/ccs_base/emulation/analysis/bin/../../../common/uscif:/opt/ti/ccsv5/ccs_base/emulation/analysis/bin/../../tpi

For C/C++ Build - Settings - Tool Settings - Cross Settings
Prefix: arm-angstrom-linux-gnueabi-
Path: /usr/local/oecore-i686/sysroots/i686-angstromsdk-linux/usr/bin/armv5te-angstrom-linux-gnueabi

The default way to compile the library looks like 'automake'. So there must be some sort of #defines that are set to configure the compile. I am unfamiliar with that tool.

If this project is not really designed to work with the MityDSP tool set, then that's fine we will try something else.

Thanks.

RE: Trying to cross compile libsodium. - Added by Jonathan Cormier over 3 years ago

https://download.libsodium.org/doc/installation/

I tried cross compiling and was able to build the library.

$ wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.12.tar.gz
$ tar xzf libsodium-1.0.12.tar.gz 
$ cd libsodium-1.0.12/
$ . /usr/local/oecore-i686/environment-setup-armv5te-angstrom-linux-gnueabi
$ export LDFLAGS='--specs=nosys.specs'
$ export CFLAGS='-Os'
$ ./configure --host=arm-angstrom-linux-gnueabi
## This failed, with error about "--specs=nosys.specs" 
$ export LDFLAGS=
$ ./configure --host=arm-angstrom-linux-gnueabi
## This worked
$ make
$ make install DESTDIR=$PWD/ARM
$ ls -R ARM/
ARM/:
usr

ARM/usr:
local

ARM/usr/local:
include  lib

ARM/usr/local/include:
sodium  sodium.h

ARM/usr/local/include/sodium:
core.h                                    crypto_core_salsa20.h                 crypto_scalarmult.h                    crypto_stream_xchacha20.h
crypto_aead_aes256gcm.h                   crypto_generichash_blake2b.h          crypto_secretbox.h                     crypto_stream_xsalsa20.h
crypto_aead_chacha20poly1305.h            crypto_generichash.h                  crypto_secretbox_xchacha20poly1305.h   crypto_verify_16.h
crypto_aead_xchacha20poly1305.h           crypto_hash.h                         crypto_secretbox_xsalsa20poly1305.h    crypto_verify_32.h
crypto_auth.h                             crypto_hash_sha256.h                  crypto_shorthash.h                     crypto_verify_64.h
crypto_auth_hmacsha256.h                  crypto_hash_sha512.h                  crypto_shorthash_siphash24.h           export.h
crypto_auth_hmacsha512256.h               crypto_kdf_blake2b.h                  crypto_sign_ed25519.h                  randombytes.h
crypto_auth_hmacsha512.h                  crypto_kdf.h                          crypto_sign_edwards25519sha512batch.h  randombytes_salsa20_random.h
crypto_box_curve25519xchacha20poly1305.h  crypto_kx.h                           crypto_sign.h                          randombytes_sysrandom.h
crypto_box_curve25519xsalsa20poly1305.h   crypto_onetimeauth.h                  crypto_stream_aes128ctr.h              runtime.h
crypto_box.h                              crypto_onetimeauth_poly1305.h         crypto_stream_chacha20.h               utils.h
crypto_core_hchacha20.h                   crypto_pwhash_argon2i.h               crypto_stream.h                        version.h
crypto_core_hsalsa20.h                    crypto_pwhash.h                       crypto_stream_salsa2012.h
crypto_core_salsa2012.h                   crypto_pwhash_scryptsalsa208sha256.h  crypto_stream_salsa208.h
crypto_core_salsa208.h                    crypto_scalarmult_curve25519.h        crypto_stream_salsa20.h

ARM/usr/local/lib:
libsodium.a  libsodium.la  libsodium.so  libsodium.so.18  libsodium.so.18.2.0  pkgconfig

ARM/usr/local/lib/pkgconfig:
libsodium.pc

Build.log View (70.8 KB)

RE: Trying to cross compile libsodium. - Added by Edwin McKay over 3 years ago

ok that looks so easy. Thanks for the details. So you did not use the Code Composer Studio at all. I will try this and also try some of these settings in CCS, but if that fails, then just use the command prompt method.

$ export LDFLAGS='--specs=nosys.specs' >>> So I guess this is not needed but that I can just 'export LDFLAGS=' and then run the ./configure
$ export CFLAGS='-Os' >>> I looked at the installation page and can now sort of follow what they are talking about.
$ ./configure --host=arm-angstrom-linux-gnueabi >>>>> Great that you knew to just ignore the '--specs=nosys.specs' and I would have assumed something was wrong with my system.
  1. This failed, with error about "--specs=nosys.specs"
    $ export LDFLAGS=
    $ ./configure --host=arm-angstrom-linux-gnueabi

RE: Trying to cross compile libsodium. - Added by Jonathan Cormier over 3 years ago

Edwin McKay wrote:

ok that looks so easy. Thanks for the details. So you did not use the Code Composer Studio at all. I will try this and also try some of these settings in CCS, but if that fails, then just use the command prompt method.

Right. There might be a way to do the configure with CCS but I've not tried.

$ export LDFLAGS='--specs=nosys.specs' >>> So I guess this is not needed but that I can just 'export LDFLAGS=' and then run the ./configure

LDFLAGS shouldn't be set by default. So you probably don't have to set it to anything.

$ export CFLAGS='-Os' >>> I looked at the installation page and can now sort of follow what they are talking about.
$ ./configure --host=arm-angstrom-linux-gnueabi >>>>> Great that you knew to just ignore the '--specs=nosys.specs' and I would have assumed something was wrong with my system.

I had to look in the config.log file for the error message. I'm guessing the --specs thing is for newer toolchains.

  1. This failed, with error about "--specs=nosys.specs"
    $ export LDFLAGS=
    $ ./configure --host=arm-angstrom-linux-gnueabi

RE: Trying to cross compile libsodium. - Added by Edwin McKay over 3 years ago

These instructions worked for me. Thanks.

    (1-6/6)
    Add picture from clipboard (Maximum size: 500 MB)