Closed schanzen closed 9 months ago
There is no particular reason, except to not introduce dependencies we don't need.
I'm fine to add it, but could you let me know what particular invocation and failure are you seeing? I don't think we're using CPU compilation targets anywhere in this project yet.
Its only later when I try to run tests, such as bazel test @heir//...
I then get errors along the lines of:
<snip>
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/tk_tcl/unix/tclUnixInit.c:11:
In file included from external/tk_tcl/generic/tclInt.h:36:
In file included from external/tk_tcl/generic/tclPort.h:23:
external/tk_tcl/unix/tclUnixPort.h:79:9: error: unknown type name 'off64_t'; did you mean 'off_t'?
typedef off64_t Tcl_SeekOffset;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_off_t.h:31:33: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
external/tk_tcl/unix/tclUnixInit.c:370:9: error: call to undeclared function 'lseek64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if (TclOSseek(0, (Tcl_SeekOffset) 0, SEEK_CUR) == -1 && errno == EBADF) {
^
external/tk_tcl/unix/tclUnixPort.h:80:23: note: expanded from macro 'TclOSseek'
# define TclOSseek lseek64
^
external/tk_tcl/unix/tclUnixInit.c:370:9: note: did you mean 'lseek'?
external/tk_tcl/unix/tclUnixPort.h:80:23: note: expanded from macro 'TclOSseek'
# define TclOSseek lseek64
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:465:8: note: 'lseek' declared here
off_t lseek(int, off_t, int);
^
2 errors generated.
Target //tests/bgv:ops.mlir.test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3.358s, Critical Path: 2.96s
INFO: 85 processes: 49 internal, 36 darwin-sandbox.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target
As I said in the OP I can run tests manually such as
bazel run //tools:heir-translate -- $PWD/tests/openfhe/emit_openfhe_pke.mlir --emit-openfhe-pke
but the tcl dependency does not work and is needed for the suites
So that dependency comes from Yosys, which uses tcl to display graph visualizations of its circuits: https://github.com/google/heir/blob/main/WORKSPACE#L174
This looks like a known issue upstream in the project that pulls in the dependencies: https://github.com/hdl/bazel_rules_hdl/issues/159
I don't think a change to the LLVM import script will impact you, not at least until we start compiling FHE programs through LLVM to a host architecture. The issue here is that your system's compiler isn't able to compile that dependency.
Yes I am aware of all that and suspected that nothing can be done about this particular error; but you asked for it so I provided some context. That is why I just asked if the AArch64 can be added to the LLVM build to make the tools compile. I do not care that much about the test suite. If course, yosys would be nice at some point. I guess another solution would be to detect the architecture and not build stuff that is known to break.
It's possible that compiling and testing without Yosys will evade that dep for you:
(This will mean you won't use any passes that depend on Yosys though of course). Instructions here! https://heir.dev/docs/getting_started/
@schanzen
I guess another solution would be to detect the architecture and not build stuff that is known to break.
I believe we can do this with a bazel config setting. I can explore it (but can't test it because I don't use it)
It's possible that compiling and testing without Yosys will evade that dep for you:
(This will mean you won't use any passes that depend on Yosys though of course). Instructions here! https://heir.dev/docs/getting_started/
Yes as I said in all three posts above, adding "AArch64" to the target list for the LLVM build in the file I linked makes the build command run through. And (selected) tests can be run manually.
I know some of the contributors to the upstream failing dependency, so I can work with them on that.
But what I meant was: what build failure are you seeing when you omit AArch64
? I'm just curious so I know why I'm adding it to the build
I know some of the contributors to the upstream failing dependency, so I can work with them on that.
But what I meant was: what build failure are you seeing when you omit
AArch64
? I'm just curious so I know why I'm adding it to the build
Ah sorry. Here you go (it is quite straight forward what the issue is):
INFO: Analyzed target //tools:heir-opt (1 packages loaded, 2294 targets configured).
INFO: Found 1 target...
INFO: From Linking external/llvm-project/llvm/llvm-min-tblgen [for tool]:
ld: warning: ignoring duplicate libraries: '-lm'
INFO: From Linking external/llvm-project/mlir/mlir-tblgen [for tool]:
ld: warning: ignoring duplicate libraries: '-lm'
INFO: From Linking external/llvm-project/llvm/llvm-tblgen [for tool]:
ld: warning: ignoring duplicate libraries: '-lm'
INFO: From Linking external/llvm-project/mlir/mlir-linalg-ods-yaml-gen [for tool]:
ld: warning: ignoring duplicate libraries: '-lm'
ERROR: /private/var/tmp/_bazel_schanzen/8bceb6bc4cc877b701d79818bdeb0609/external/llvm-project/llvm/BUILD.bazel:1176:11: Compiling llvm/lib/Target/Target.cpp failed: (Exit 1): cc_wrapper.sh failed: error executing command (from target @llvm-project//llvm:Target) external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics ... (remaining 95 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/llvm-project/llvm/lib/Target/Target.cpp:14:
external/llvm-project/llvm/include/llvm-c/Target.h:134:3: error: use of undeclared identifier 'LLVMInitializeAArch64TargetInfo'; did you mean 'LLVMInitializeX86TargetInfo'?
LLVM_NATIVE_TARGETINFO();
^
<command line>:28:32: note: expanded from macro 'LLVM_NATIVE_TARGETINFO'
#define LLVM_NATIVE_TARGETINFO LLVMInitializeAArch64TargetInfo
^
bazel-out/darwin_arm64-dbg/bin/external/llvm-project/llvm/include/llvm/Config/Targets.def:26:1: note: 'LLVMInitializeX86TargetInfo' declared here
LLVM_TARGET(X86)
^
external/llvm-project/llvm/include/llvm-c/Target.h:42:8: note: expanded from macro 'LLVM_TARGET'
void LLVMInitialize##TargetName##TargetInfo(void);
^
<scratch space>:369:1: note: expanded from here
LLVMInitializeX86TargetInfo
^
In file included from external/llvm-project/llvm/lib/Target/Target.cpp:14:
external/llvm-project/llvm/include/llvm-c/Target.h:135:3: error: use of undeclared identifier 'LLVMInitializeAArch64Target'; did you mean 'LLVMInitializeX86Target'?
LLVM_NATIVE_TARGET();
^
<command line>:27:28: note: expanded from macro 'LLVM_NATIVE_TARGET'
#define LLVM_NATIVE_TARGET LLVMInitializeAArch64Target
^
bazel-out/darwin_arm64-dbg/bin/external/llvm-project/llvm/include/llvm/Config/Targets.def:26:1: note: 'LLVMInitializeX86Target' declared here
LLVM_TARGET(X86)
^
external/llvm-project/llvm/include/llvm-c/Target.h:46:38: note: expanded from macro 'LLVM_TARGET'
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void);
^
<scratch space>:373:1: note: expanded from here
LLVMInitializeX86Target
^
In file included from external/llvm-project/llvm/lib/Target/Target.cpp:14:
external/llvm-project/llvm/include/llvm-c/Target.h:136:3: error: use of undeclared identifier 'LLVMInitializeAArch64TargetMC'; did you mean 'LLVMInitializeX86TargetMC'?
LLVM_NATIVE_TARGETMC();
^
<command line>:29:30: note: expanded from macro 'LLVM_NATIVE_TARGETMC'
#define LLVM_NATIVE_TARGETMC LLVMInitializeAArch64TargetMC
^
bazel-out/darwin_arm64-dbg/bin/external/llvm-project/llvm/include/llvm/Config/Targets.def:26:1: note: 'LLVMInitializeX86TargetMC' declared here
LLVM_TARGET(X86)
^
external/llvm-project/llvm/include/llvm-c/Target.h:51:8: note: expanded from macro 'LLVM_TARGET'
void LLVMInitialize##TargetName##TargetMC(void);
^
<scratch space>:377:1: note: expanded from here
LLVMInitializeX86TargetMC
^
In file included from external/llvm-project/llvm/lib/Target/Target.cpp:14:
external/llvm-project/llvm/include/llvm-c/Target.h:148:3: error: use of undeclared identifier 'LLVMInitializeAArch64AsmParser'; did you mean 'LLVMInitializeX86AsmParser'?
LLVM_NATIVE_ASMPARSER();
^
<command line>:24:31: note: expanded from macro 'LLVM_NATIVE_ASMPARSER'
#define LLVM_NATIVE_ASMPARSER LLVMInitializeAArch64AsmParser
^
bazel-out/darwin_arm64-dbg/bin/external/llvm-project/llvm/include/llvm/Config/AsmParsers.def:27:1: note: 'LLVMInitializeX86AsmParser' declared here
LLVM_ASM_PARSER(X86)
^
external/llvm-project/llvm/include/llvm-c/Target.h:63:8: note: expanded from macro 'LLVM_ASM_PARSER'
void LLVMInitialize##TargetName##AsmParser(void);
^
<scratch space>:385:1: note: expanded from here
LLVMInitializeX86AsmParser
^
In file included from external/llvm-project/llvm/lib/Target/Target.cpp:14:
external/llvm-project/llvm/include/llvm-c/Target.h:160:3: error: use of undeclared identifier 'LLVMInitializeAArch64AsmPrinter'; did you mean 'LLVMInitializeX86AsmPrinter'?
LLVM_NATIVE_ASMPRINTER();
^
<command line>:25:32: note: expanded from macro 'LLVM_NATIVE_ASMPRINTER'
#define LLVM_NATIVE_ASMPRINTER LLVMInitializeAArch64AsmPrinter
^
bazel-out/darwin_arm64-dbg/bin/external/llvm-project/llvm/include/llvm/Config/AsmPrinters.def:27:1: note: 'LLVMInitializeX86AsmPrinter' declared here
LLVM_ASM_PRINTER(X86)
^
external/llvm-project/llvm/include/llvm-c/Target.h:57:8: note: expanded from macro 'LLVM_ASM_PRINTER'
void LLVMInitialize##TargetName##AsmPrinter(void);
^
<scratch space>:381:1: note: expanded from here
LLVMInitializeX86AsmPrinter
^
In file included from external/llvm-project/llvm/lib/Target/Target.cpp:14:
external/llvm-project/llvm/include/llvm-c/Target.h:172:3: error: use of undeclared identifier 'LLVMInitializeAArch64Disassembler'; did you mean 'LLVMInitializeX86Disassembler'?
LLVM_NATIVE_DISASSEMBLER();
^
<command line>:26:34: note: expanded from macro 'LLVM_NATIVE_DISASSEMBLER'
#define LLVM_NATIVE_DISASSEMBLER LLVMInitializeAArch64Disassembler
^
bazel-out/darwin_arm64-dbg/bin/external/llvm-project/llvm/include/llvm/Config/Disassemblers.def:27:1: note: 'LLVMInitializeX86Di
sassembler' declared here
LLVM_DISASSEMBLER(X86)
^
external/llvm-project/llvm/include/llvm-c/Target.h:69:8: note: expanded from macro 'LLVM_DISASSEMBLER'
void LLVMInitialize##TargetName##Disassembler(void);
^
<scratch space>:387:1: note: expanded from here
LLVMInitializeX86Disassembler
^
6 errors generated.
Target //tools:heir-opt failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 137.889s, Critical Path: 21.86s
INFO: 774 processes: 9 internal, 765 darwin-sandbox.
FAILED: Build did NOT complete successfully
Ah, perfect, thanks!
@schanzen if you have a moment, would you be willing to test https://github.com/hdl/bazel_rules_hdl/pull/278 ? It should be quick.
Hi,
is there any reason why AArch64 is specifically not enabled? In particular, https://github.com/google/heir/blob/main/bazel/setup_llvm.bzl#L9 only enables x86 and the build will fail on macOS. Adding "AArch64" as target did work for me and allow everything to compile, and I was able to manually run a test. So it seems to me to work, at least partially.
Br