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

Makefile does not account for older toolchains #6

Closed
technotive opened this issue Apr 26, 2018 · 2 comments
Closed

Makefile does not account for older toolchains #6

technotive opened this issue Apr 26, 2018 · 2 comments

Comments

@technotive
Copy link

technotive commented Apr 26, 2018

Edits; Markdown fix.

In the process of trying to get the standard benchmarks to work according to the readme. At this point I am at the "Running tests and benchmarks" part of the readme.
Linuxmint 17.3 (Rosa) with GCC/G++ 5.5 has the following output when calling make:

make -C crypto_kem/frodo640-cshake/opt libpqm4.a
make[1]: Entering directory '/home/nevy/Research/pqm4/crypto_kem/frodo640-cshake/opt'
arm-none-eabi-gcc -I/home/nevy/Research/pqm4/common -Wall -Wextra -O3 -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -c -o frodo640.o frodo640.c
In file included from frodo640.c:30:0:
kem.c: In function 'crypto_kem_dec':
kem.c:129:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < PARAMS_N*PARAMS_NBAR; i++) BBp[i] = BBp[i] & ((1 << PARAMS_LOGQ)-1);
     ^
kem.c:129:5: note: use option -std=c99 or -std=gnu99 to compile your code
In file included from frodo640.c:32:0:
frodo_macrify.c: In function 'frodo_add':
frodo_macrify.c:222:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < (PARAMS_NBAR*PARAMS_NBAR); i++) {
     ^
frodo_macrify.c: In function 'frodo_sub':
frodo_macrify.c:233:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < (PARAMS_NBAR*PARAMS_NBAR); i++) {
     ^
make[1]: *** [frodo640.o] Error 1
make[1]: Leaving directory '/home/nevy/Research/pqm4/crypto_kem/frodo640-cshake/opt'
make: *** [crypto_kem/frodo640-cshake/opt] Error 2

Which is supposedly remedied by:
make CFLAGS="-std=gnu99"
Which results in:

...
newhope_asm.S:734: Error: attempt to use an ARM instruction on a Thumb-only processor -- 'pop {r0-r12,pc}'
make[1]: *** [newhope_asm.o] Error 1
rm kem.o cpapke.o
make[1]: Leaving directory '/home/nevy/Research/pqm4/crypto_kem/newhope1024cca/m4'
make: *** [crypto_kem/newhope1024cca/m4] Error 2

On the first run.

Then we run make again, and then make CFLAGS="-std=gnu99" again to get

...
make[1]: Leaving directory '/home/nevy/Research/pqm4/crypto_sign/sphincs-shake256-128s/ref'
make -C crypto_sign/sphincs-shake256-128s/ref libpqhost.a
make[1]: Entering directory '/home/nevy/Research/pqm4/crypto_sign/sphincs-shake256-128s/ref'
gcc -I/home/nevy/Research/pqm4/common -Wall -Wextra -O3 -c -o hash_shake256_host.o hash_shake256.c
gcc -I/home/nevy/Research/pqm4/common -Wall -Wextra -O3 -c -o hash_address_host.o hash_address.c
gcc -I/home/nevy/Research/pqm4/common -Wall -Wextra -O3 -c -o wots_host.o wots.c
gcc -I/home/nevy/Research/pqm4/common -Wall -Wextra -O3 -c -o utils_host.o utils.c
gcc -I/home/nevy/Research/pqm4/common -Wall -Wextra -O3 -c -o fors_host.o fors.c
gcc -I/home/nevy/Research/pqm4/common -Wall -Wextra -O3 -c -o sign_host.o sign.c
gcc-ar rcs libpqhost.a hash_shake256_host.o hash_address_host.o wots_host.o utils_host.o fors_host.o sign_host.o
make[1]: Leaving directory '/home/nevy/Research/pqm4/crypto_sign/sphincs-shake256-128s/ref'
mkdir -p obj 
arm-none-eabi-gcc -std=gnu99 -o obj/stm32f4_wrapper.o -c common/stm32f4_wrapper.c
In file included from common/stm32f4_wrapper.c:1:0:
common/stm32wrapper.h:4:34: fatal error: libopencm3/stm32/rcc.h: No such file or directory
 #include <libopencm3/stm32/rcc.h>
                                  ^
compilation terminated.
make: *** [obj/stm32f4_wrapper.o] Error 1

After which a regular make results in:

...
arm-none-eabi-gcc -O3 -Wall -Wextra -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wundef -Wshadow -I./libopencm3/include -fno-common -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=gnu99 -MD -DSTM32F4 -std=gnu99 -o obj/stm32f4_wrapper.o -c common/stm32f4_wrapper.c
In file included from ./libopencm3/include/libopencm3/cm3/nvic.h:133:0,
                 from common/stm32wrapper.h:7,
                 from common/stm32f4_wrapper.c:1:
./libopencm3/include/libopencm3/dispatch/nvic.h:14:39: fatal error: libopencm3/stm32/f4/nvic.h: No such file or directory
 # include <libopencm3/stm32/f4/nvic.h>
                                       ^
compilation terminated.
make: *** [obj/stm32f4_wrapper.o] Error 1

At which point alternating both method does not change anything anymore.

Calling make clean will revert the situation to the way it was at the beginning of this message.

Note that I originally updated from GCC 4.8 (Which showed similar behaviour) to GCC 5.5 because I read that gnu11 is the new default for GCC 5.5, which would make messing with the CFLAG unessecary. Sadly, GCC 5.5 did not deliver what I thought it would.

It looks like some libraries need the "-std=gnu99" flag but somehow either something else gets misconfigured because of it, or it was misconfigured from the start. Can someone help me debug this? I am not an expert when it comes to Makefiles, so it might as well be I just forgot something.

@technotive
Copy link
Author

Additional information:
Adjusting Frodo to be compliant with c89/gnu89 by moving variable declarations out of for-loops results in the following error when calling make:

arm-none-eabi-gcc -O3 -Wall -Wextra -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wundef -Wshadow -I./libopencm3/include -fno-common -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=gnu99 -MD -DSTM32F4 -std=gnu99 -o obj/stm32f4_wrapper.o -c common/stm32f4_wrapper.c
In file included from ./libopencm3/include/libopencm3/cm3/nvic.h:133:0,
                 from common/stm32wrapper.h:7,
                 from common/stm32f4_wrapper.c:1:
./libopencm3/include/libopencm3/dispatch/nvic.h:14:39: fatal error: libopencm3/stm32/f4/nvic.h: No such file or directory
 # include <libopencm3/stm32/f4/nvic.h>
                                       ^
compilation terminated.
make: *** [obj/stm32f4_wrapper.o] Error 1

@technotive
Copy link
Author

technotive commented Apr 26, 2018

independently first calling make for libopencm3 solved the issue in combination with making Frodo c89/gnu89 compliant.

@technotive technotive changed the title Makefile does not accoutn for older toolchains Makefile does not account for older toolchains Apr 26, 2018
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

1 participant