linuxmakefilegoogle-nativeclientlibtomcrypt

Can't build .nexe file with libtomcrypt. Compile errors


I'm trying to compile nexe files with nacplorts lib libtomcrypt. Building nexe it returns error of bunch of "undefined". I have tried building with different flag but nothing. Maybe someone can point out what I'm doing wrong or what I'm missing in current setup.

Result. Errors.

$ make
  LINK newlib/Release/myproj_unstripped_x86_32.nexe
/home/ME/nacl/pepper_35/toolchain/linux_x86_newlib/i686-nacl/usr/lib/libtomcrypt.a(aes.o): In function `rijndael_test':
aes.c:(.text+0x1271): undefined reference to `__stack_chk_fail'
/home/ME/nacl/pepper_35/toolchain/linux_x86_newlib/i686-nacl/usr/lib/libtomcrypt.a(crypt_argchk.o): In function `crypt_argchk':
crypt_argchk.c:(.text+0x1c): undefined reference to `stderr'
crypt_argchk.c:(.text+0x34): undefined reference to `__fprintf_chk'
collect2: ld returned 1 exit status
make: *** [newlib/Release/myproj_unstripped_x86_32.nexe] Error 1

Makefile

VALID_TOOLCHAINS := newlib glibc pnacl linux

NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..)

include $(NACL_SDK_ROOT)/tools/common.mk

TARGET = myproj
LIBS = ppapi_cpp ppapi pthread tomcrypt 

CFLAGS = -Wall
SOURCES = myproj.cc

# Build rules generated by macros from common.mk:

$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))

ifeq ($(CONFIG),Release)
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
endif

$(eval $(call NMF_RULE,$(TARGET),))

myproj.cc

Code contains only one line, that triggers all errors. Maybe i didn't add something more. I'm new to tomcrypt and not very good with C code but willing to learn. And if this code shouldn't compile can you give me example of simple "minimum-lines" code that uses tomcrypt but doesn't do anything complex? To be sure i can go further.

#include <tomcrypt.h>
//...

virtual void HandleMessage(const pp::Var& var) {

    register_cipher(&aes_desc); // <----------- without this line build is successful

    //...
}

//...

Solution

  • It looks like the libtomcrypt build in naclports was never working correctly. Bug and fix in review here: https://code.google.com/p/naclports/issues/detail?id=134