Skip to content

Commit

Permalink
fix: add blst/build
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkeil committed Jan 25, 2024
1 parent 8c6547c commit d6de608
Show file tree
Hide file tree
Showing 98 changed files with 106,886 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typings/
dist/
lib/
!temp-deps/lib/
!temp-deps/blst-ts/deps/blst/build
benchmark-reports

.vscode/
Expand Down
2 changes: 2 additions & 0 deletions temp-deps/blst-ts/deps/blst/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ bindings/node.js
bindings/emscripten
bin/
obj/

!build/
123 changes: 123 additions & 0 deletions temp-deps/blst-ts/deps/blst/build/assembly.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#if defined(__x86_64) || defined(__x86_64__)
# if defined(__ELF__)
# if defined(__BLST_PORTABLE__)
# include "elf/sha256-portable-x86_64.s"
# else
# include "elf/sha256-x86_64.s"
# endif
# if defined(__ADX__) && !defined(__BLST_PORTABLE__)
# include "elf/ctx_inverse_mod_384-x86_64.s"
# else
# include "elf/ctq_inverse_mod_384-x86_64.s"
# endif
# include "elf/add_mod_384-x86_64.s"
# include "elf/add_mod_384x384-x86_64.s"
# define __add_mod_384 __add_mont_384
# define __sub_mod_384 __sub_mont_384
# define __sub_mod_384x384 __sub_mont_384x384
# if defined(__ADX__) && !defined(__BLST_PORTABLE__)
# include "elf/mulx_mont_384-x86_64.s"
# include "elf/mulx_mont_256-x86_64.s"
# else
# include "elf/mulq_mont_384-x86_64.s"
# include "elf/mulq_mont_256-x86_64.s"
# endif
# include "elf/add_mod_256-x86_64.s"
# include "elf/ct_inverse_mod_256-x86_64.s"
# include "elf/div3w-x86_64.s"
# include "elf/ct_is_square_mod_384-x86_64.s"
# elif defined(_WIN64) || defined(__CYGWIN__)
# if defined(__BLST_PORTABLE__)
# include "coff/sha256-portable-x86_64.s"
# else
# include "coff/sha256-x86_64.s"
# endif
# if defined(__ADX__) && !defined(__BLST_PORTABLE__)
# include "coff/ctx_inverse_mod_384-x86_64.s"
# else
# include "coff/ctq_inverse_mod_384-x86_64.s"
# endif
# include "coff/add_mod_384-x86_64.s"
# include "coff/add_mod_384x384-x86_64.s"
# define __add_mod_384 __add_mont_384
# define __sub_mod_384 __sub_mont_384
# define __sub_mod_384x384 __sub_mont_384x384
# if defined(__ADX__) && !defined(__BLST_PORTABLE__)
# include "coff/mulx_mont_384-x86_64.s"
# include "coff/mulx_mont_256-x86_64.s"
# else
# include "coff/mulq_mont_384-x86_64.s"
# include "coff/mulq_mont_256-x86_64.s"
# endif
# include "coff/add_mod_256-x86_64.s"
# include "coff/ct_inverse_mod_256-x86_64.s"
# include "coff/div3w-x86_64.s"
# include "coff/ct_is_square_mod_384-x86_64.s"
# elif defined(__APPLE__)
# include "mach-o/sha256-x86_64.s"
# if defined(__ADX__) && !defined(__BLST_PORTABLE__)
# include "mach-o/ctx_inverse_mod_384-x86_64.s"
# else
# include "mach-o/ctq_inverse_mod_384-x86_64.s"
# endif
# include "mach-o/add_mod_384-x86_64.s"
# include "mach-o/add_mod_384x384-x86_64.s"
# define __add_mod_384 __add_mont_384
# define __sub_mod_384 __sub_mont_384
# define __sub_mod_384x384 __sub_mont_384x384
# if defined(__ADX__) && !defined(__BLST_PORTABLE__)
# include "mach-o/mulx_mont_384-x86_64.s"
# include "mach-o/mulx_mont_256-x86_64.s"
# else
# include "mach-o/mulq_mont_384-x86_64.s"
# include "mach-o/mulq_mont_256-x86_64.s"
# endif
# include "mach-o/add_mod_256-x86_64.s"
# include "mach-o/ct_inverse_mod_256-x86_64.s"
# include "mach-o/div3w-x86_64.s"
# include "mach-o/ct_is_square_mod_384-x86_64.s"
# endif
#elif defined(__aarch64__)
# if defined(__ELF__)
# include "elf/sha256-armv8.S"
# include "elf/ct_inverse_mod_384-armv8.S"
# include "elf/add_mod_384-armv8.S"
# define __add_mod_384 __add_mont_384
# define __sub_mod_384 __sub_mont_384
# include "elf/mul_mont_384-armv8.S"
# include "elf/mul_mont_256-armv8.S"
# include "elf/add_mod_256-armv8.S"
# include "elf/ct_inverse_mod_256-armv8.S"
# include "elf/div3w-armv8.S"
# include "elf/ct_is_square_mod_384-armv8.S"
# elif defined(_WIN64)
# include "coff/sha256-armv8.S"
# include "coff/ct_inverse_mod_384-armv8.S"
# include "coff/add_mod_384-armv8.S"
# define __add_mod_384 __add_mont_384
# define __sub_mod_384 __sub_mont_384
# include "coff/mul_mont_384-armv8.S"
# include "coff/mul_mont_256-armv8.S"
# include "coff/add_mod_256-armv8.S"
# include "coff/ct_inverse_mod_256-armv8.S"
# include "coff/div3w-armv8.S"
# include "coff/ct_is_square_mod_384-armv8.S"
# elif defined(__APPLE__)
# include "mach-o/sha256-armv8.S"
# include "mach-o/ct_inverse_mod_384-armv8.S"
# include "mach-o/add_mod_384-armv8.S"
# define __add_mod_384 __add_mont_384
# define __sub_mod_384 __sub_mont_384
# include "mach-o/mul_mont_384-armv8.S"
# include "mach-o/mul_mont_256-armv8.S"
# include "mach-o/add_mod_256-armv8.S"
# include "mach-o/ct_inverse_mod_256-armv8.S"
# include "mach-o/div3w-armv8.S"
# include "mach-o/ct_is_square_mod_384-armv8.S"
# endif
#elif defined(__BLST_NO_ASM__) || \
(defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__==4)
/* inaccurate way to detect a 32-bit processor, but it's close enough */
#else
# error "unsupported platform"
#endif
37 changes: 37 additions & 0 deletions temp-deps/blst-ts/deps/blst/build/bindings_trim.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env perl

# read whole file
while(<>) { push @file, $_; }

# traverse and remove auto-generated PartialEq for chosen types
for (my $i = 0; $i <= $#file; $i++) {
if (@file[$i] =~ m/struct\s+blst_p[12]/) {
@file[$i-1] =~ s/,\s*PartialEq//;
} elsif (@file[$i] =~ m/struct\s+blst_fp12/) {
@file[$i-1] =~ s/,\s*(?:Default|PartialEq)//g;
} elsif (@file[$i] =~ m/struct\s+(blst_pairing|blst_uniq)/) {
@file[$i-1] =~ s/,\s*(?:Copy|Clone|Eq|PartialEq)//g;
} elsif (@file[$i] =~ m/struct\s+blst_scalar/) {
@file[$i-1] =~ s/,\s*Copy//;
@file[$i-1] =~ s/\)/, Zeroize\)/;
splice @file, $i, 0, "#[zeroize(drop)]\n"; $i++;
} elsif (@file[$i] =~ m/assert_eq!\($/) {
@file[++$i] =~ s/unsafe\s*\{\s*&\(\*\(::std::ptr::null::<(\w+)>\(\)\)\)\.(\w+).*\}/offsetof!($1, $2)/;
}
}

print << '___';
#[cfg(test)]
macro_rules! offsetof {
($type:ty, $field:tt) => {
unsafe {
let v = std::mem::MaybeUninit::<$type>::uninit().assume_init();
(&v.$field as *const _ as usize) - (&v as *const _ as usize)
}
};
}
___
# print the file
print @file;

close STDOUT;
Loading

0 comments on commit d6de608

Please sign in to comment.