herumi / bls

288 stars 132 forks source link

Compiling i386 on a x86_64 system seems to still produce x86_64 libs #92

Closed mxaddict closed 1 year ago

mxaddict commented 1 year ago

Compiled with this:

clang++ -m32 -std=c++17 -pipe -std=c++17 -O1  -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -Wundef -m64 -I include -I test -fomit-frame-pointer -DNDEBUG -fno-stack-protector -O3  -DMCL_USE_VINT -DMCL_DONT_USE_OPENSSL -fPIC -c src/fp.cpp -o obj/fp.o -MMD -MP -MF obj/fp.d

But when linking the libs getting this error:

/usr/bin/ld: i386:x86-64 architecture of input file `bls/mcl/lib/libmcl.a(fp.o)' is incompatible with i386 output
mxaddict commented 1 year ago

I noticed that build is adding -m64 to via the mcl/common.mk logic:

ifneq ($(findstring $(ARCH),x86_64/amd64),)
  CPU=x86-64
  INTEL=1
  ifeq ($(findstring $(OS),mingw64/cygwin),)
    GCC_EXT=1
  endif
  BIT=64
  BIT_OPT=-m64
  #LOW_ASM_SRC=src/asm/low_x86-64.asm
  #ASM=nasm -felf64
endif

The issue is that we are trying to compile for 32bit on an x64 system

Our HOST is set as i686-pc-linux-gnu

I was planning on using the HOST value to pass ARCH to bls and mcl during build, but the mcl/common.mk is only checking for uname -m what is x86 here:

ifeq ($(ARCH),x86)
  CPU=x86
  INTEL=1
  BIT=32
  BIT_OPT=-m32
  #LOW_ASM_SRC=src/asm/low_x86.asm
endif
mxaddict commented 1 year ago

I think running make as ARCH=x86 make should fix this, but it's kinda janky due to the fact that we are using host i686.

herumi commented 1 year ago

Thank you for the nice patch.

mxaddict commented 1 year ago

Thank you for the nice patch.

No problem, thanks for the library 👍🏼