herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 152 forks source link

Building MCL on system with gcc/g++ and no clang/clang++ fails #153

Closed mxaddict closed 1 year ago

mxaddict commented 1 year ago

Building on a system with gcc/g++ only fails due to BINT_SRC build step

$(BINT_SRC): src/bint$(BIT).ll
    clang++$(LLVM_VER) -S $< -o $@ -no-integrated-as -fpic -O2 -DNDEBUG -Wall -Wextra $(CLANG_TARGET) $(CFLAGS_USER)

How would one go about building these without the use of clang++ ?

mxaddict commented 1 year ago

Also, when cross compiling for 32bit on a 64bit host machine, $(BINT_SRC) build for src/bint$(BIT).ll is not passing -m32

mxaddict commented 1 year ago

Also, when cross compiling for 32bit on a 64bit host machine, $(BINT_SRC) build for src/bint$(BIT).ll is not passing -m32

I created PR #154 to resolve 32bit cross compile from 64bit system.

herumi commented 1 year ago

How would one go about building these without the use of clang++ ?

I add precompiled asm files for x64 to build without clang++. But for the other architectures, I don't prepare them because it bothers me (and clang is a default compiler on macOS and FreeBSD, etc.).

mxaddict commented 1 year ago

I see, would it make sense for me to make a PR for the precompiled asm files?

On Fri, Sep 2, 2022, 08:53 MITSUNARI Shigeo @.***> wrote:

How would one go about building these without the use of clang++ ?

I add precompiled asm files for x64 to build without clang++. But for the other architectures, I don't prepare them because it bothers me (and clang is a default compiler on macOS and FreeBSD, etc.).

— Reply to this email directly, view it on GitHub https://github.com/herumi/mcl/issues/153#issuecomment-1234949070, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIDAKJZOMBKRXRISDYBL4DV4FFXBANCNFSM6AAAAAAQCQVYKY . You are receiving this because you authored the thread.Message ID: @.***>

herumi commented 1 year ago

For security reasons, I want to commit the asm files to my repository by myself. I don't want to prepare for too many environments, but what environment do you need them for?

mxaddict commented 1 year ago

The issue we are facing is we do cross compiling on our project, so we build on Linux 64bit, but target other platforms from it.

Some of the builds in the CI system use gcc/g++ so it's failing to create the asm files.

We are currently targeting the following:

herumi commented 1 year ago

To build for Android/NDK, you have to install android-studio and clang, so I would not like to add precompiled files. May I provide Android.mk such as https://github.com/herumi/bls/blob/master/android/jni/Android.mk?

I don't know how to cross-compile for the other environments, but can you use clang for them? clang -target may be able to generate asm files (see clang++-12 -print-targets).

mxaddict commented 1 year ago

To build for Android/NDK, you have to install android-studio and clang, so I would not like to add precompiled files. May I provide Android.mk such as https://github.com/herumi/bls/blob/master/android/jni/Android.mk?

I don't know how to cross-compile for the other environments, but can you use clang for them? clang -target may be able to generate asm files (see clang++-12 -print-targets).

I'll take a look and see what is required.

mxaddict commented 1 year ago

@herumi I think it might be possible to generate the asm files for all the platforms via osx/linux clang and set -target like you suggested.

Would you like me to create a simple bash/python file that would generate/update the asm files based on the bint$(BIT).ll files?

We could add it as a step in Makefile and you can run these whenever updates are needed

herumi commented 1 year ago

Would you like me to create a simple bash/python file that would generate/update the asm files based on the bint$(BIT).ll files?

It looks good. I'll check it.