herumi / mcl

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

Added makefile command for creating /src/asm/bint$BIT.ll-$ARCH.s files #162

Closed mxaddict closed 1 year ago

mxaddict commented 1 year ago

Related to https://github.com/herumi/mcl/issues/153

mxaddict commented 1 year ago

@herumi I've created this build step that can create asm files as needed, could you give this a test?

mxaddict commented 1 year ago

@herumi have you had a moment to check this?

herumi commented 1 year ago

Sorry, I have to save my job because I got a bad headache. I'll check it little by little.

mxaddict commented 1 year ago

Sorry, I have to save my job because I got a bad headache. I'll check it little by little.

No worries 👍🏼

herumi commented 1 year ago

Now the name of a generated asm from bint$(BIT).ll is generically src/asm/bint$(BIT)-$(OS)-$(CPU). But the name in your patch is bint$(BIT)-$(CPU). I append $(OS) to distinguish M1 Mac and AArch64 Linux / x64 Linux and x64 Windows. Don't you think that's necessary? If so, how about src/bint-$(TARGET) -target $(TARGET)? It is simple.

herumi commented 1 year ago

Which do you need, lib/libmcl.a or lib/bn384_256.a ?

mxaddict commented 1 year ago

we need lib/libmcl.a to link against herumi/bls

mxaddict commented 1 year ago

I'm not sure actually, cause I noticed that linux aarch64 and mac arm64 when creating the asm files had the same results when using the same clang versions. so I think they are interchangeable.

mxaddict commented 1 year ago

I'm not sure actually, cause I noticed that linux aarch64 and mac arm64 when creating the asm files had the same results when using the same clang versions. so I think they are interchangeable.

I think we might need to do more investigation

herumi commented 1 year ago

we need lib/libmcl.a to link against herumi/bls

Then, I think that it is better to modify bls/Makefile.onelib . I'll let it support cross-compile.

mxaddict commented 1 year ago

Would this mean compiling bls, but without having a libmcl.a ?

herumi commented 1 year ago

Would this mean compiling bls, but without having a libmcl.a ?

At first, libmcl.a was developed separately. But for convenience of libbls, it contains libmcl.a in bls-eth-go-binary. It is not so good, but it remains for backward compatibility. bls/Makefile.one lib is to make the library.

https://github.com/herumi/bls/blob/dev/Makefile.onelib#L180-L186 seems to be able to make libbls384_256.a for aarch64 and i686 on x86-64 Linux. Could you check it? If it is okay, I'll add the other configuration.

mxaddict commented 1 year ago

Would this mean compiling bls, but without having a libmcl.a ?

At first, libmcl.a was developed separately. But for convenience of libbls, it contains libmcl.a in bls-eth-go-binary. It is not so good, but it remains for backward compatibility. bls/Makefile.one lib is to make the library.

https://github.com/herumi/bls/blob/dev/Makefile.onelib#L180-L186 seems to be able to make libbls384_256.a for aarch64 and i686 on x86-64 Linux. Could you check it? If it is okay, I'll add the other configuration.

I'll check it out.

herumi commented 1 year ago

This command is https://github.com/herumi/mcl/blob/master/Makefile#L189-L190

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