ferrandi / PandA-bambu

PandA-bambu public repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error building on Mac OS

thechosenone98 opened this issue · comments

When trying to run:

../configure --enable-lattice --prefix=/opt/panda

I get the following error:

checking for boostlib >= 1.48.0... yes
checking whether the Boost::System library is available... yes
checking for main in -lboost_system... yes
checking whether the Boost::Date_Time library is available... yes
checking for exit in -lboost_date_time... yes
checking whether the Boost::Filesystem library is available... yes
checking for main in -lboost_filesystem... yes
checking whether the Boost::Regex library is available... yes
checking for exit in -lboost_regex... yes
configure: error: "Error in linking boost filesystem library"

I have the boost libraries installed via Homebrew so there should be no problem.
I have tried exporting the LD_LIBRARY_PATH and DYLD_LIBRARY_PATH myself and pointing to the lib folder of the boost libraries but it didn't change anything. Could you please look into this quickly as I am in a bit of an urgent situation.

Thank you :)

Hello,
Bambu has not been extensively used nor tested on Mac OS, so the configuration process is set up for Ubuntu.

Hi,
the fastest way I can suggest to solve the issue is to build using docker. The binaries are statically linked, so it should be fine to run them from the host machine too (though I am not aware if that is also the case on macOS).
Though if you just need to use PandA bambu rather than modify the source code I suggest you download the AppImage from https://release.bambuhls.eu/bambu-0.9.8.AppImage .

Please let me know if that helps, in the meanwhile, I will try to reproduce the issue.

Hi,
my suggestion is to use the --with-boost-regex option of the configure. Configure has some options to deal with boost libraries (./configure --help).
Please let us know if you succeed or not. It is a bit complicated to test the code base against macOS.
Cheers,
Fabrizio

I also noticed that at the top of the output there is a warning about --enable-lattice not being recognized (actually if I try to follow your install directive on your website and use this line:

../configure --prefix=/opt/panda --enable-flopoco --enable-icarus --enable-verilator --enable-xilinx --enable-modelsim --enable-altera --enable-opt --enable-lattice --enable-release

None of the arguments are recognized

The website is a little outdated with respect to the repository, I am sorry about that. You should refer to the INSTALL file in the repository for updated install instructions. The --enable-<vendor_tool> and --enable-<simulator> options have been removed, they are all included in the build and only checked at runtime if necessary so that you can generate simulation and synthesis scripts without the need for the tools to be installed.

Ok one final question then, is this crashing because my machine is running an ARM processor (I tried installing the AppImage on Ubuntu VM and I get and exec format error suggesting a problem with the architecture I'm using)

Ok one final question then, is this crashing because my machine is running an ARM processor (I tried installing the AppImage on Ubuntu VM and I get and exec format error suggesting a problem with the architecture I'm using)

The appImage binary is meant for Intel-based architectures running on Linux.

I am working through the build process on an M2. I use homebrew. This sequence worked for me:


brew install autoconf automake bison flex boost libtool SuiteSparse glpk mpfi coreutils mpfr boost libxml2 icu4c

git clone https://github.com/ferrandi/PandA-bambu.git
cd PandA-bambu
make -f Makefile.init
mkdir build
cd build
./configure --prefix=`pwd` --enable-verilator --enable-glpk --enable-opt --enable-flopoco --with-opt-level=fast --with-boost=/opt/homebrew/Cellar/boost/1.80.0/ LDFLAGS="-L/opt/homebrew/lib" CPPFLAGS="-I/opt/homebrew/include/" --with-icu=/opt/homebrew/Cellar/icu4c/71.1/

However, it fails to build Sollya with this error:

/Users/drichmond/Research/repositories/git/PandA-bambu/etc/macros/../../ext/sollya/double.c:1259:5: error: implicit declaration of function 'mpfr_round_to_doubleextended_mode' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

Which I know how to fix, but ideally I don't have to modify the source code. I have to switch to working on other tasks, but I figured I'd put my progress here in case it helps others.

Edit: i've tried to add CFLAGS="-std=c89 -Wno-implicit-function-declaration" without success.

Edit 2: I've successfully applied -Wno-implicit-function-declaration, but now it fails with configure: error: "gcc with support to -m32 and plugin not found"

Does bambu require 32-bit support? That is not available on MacOS.

I was able to successfully get through most of bambu compilation on my m2.

brew install autoconf automake bison flex boost libtool SuiteSparse glpk mpfi coreutils mpfr boost libxml2 icu4c llvm@12

git clone https://github.com/ferrandi/PandA-bambu.git
cd PandA-bambu
make -f Makefile.init
mkdir build
cd build
PATH="/opt/homebrew/opt/bison/bin:$PATH" ../configure --prefix=`pwd` --enable-verilator --enable-latice --enable-opt --with-boost=/opt/homebrew/Cellar/boost/1.80.0/ LDFLAGS="-L/opt/homebrew/lib" CPPFLAGS="-I/opt/homebrew/include/" --with-icu=/opt/homebrew/Cellar/icu4c/71.1/ --with-clang12=/opt/homebrew/opt/llvm@12/bin/clang
PATH="/opt/homebrew/opt/bison/bin:$PATH" make

Key changes:
0. I wasnln't able

  1. Default bison is too old to support %code (See PATH=...)
  2. LLVM-12 needs to be installed by homebrew (default on my m2 was llvm-14)
  3. -march=native is not supported until llvm/clang 15 (see diff below)
  4. finite/isfinite (see libfpll diff)
  5. Undefined references are treated differently in modern gcc/clang (see configure.ac diff)
  6. whole-archive is not supported (use force_load instead)

It required this diff:

diff --git a/configure.ac b/configure.ac
index fb06c9dc1..fc03a4e53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1265,7 +1265,7 @@ if test "x$panda_USE_FLOPOCO" = xyes; then
       AC_MSG_ERROR("Error in sollya configuration")
    fi
    cd ext/sollya
-   make
+   make CFLAGS=-Wno-implicit-function-declaration
    make install
    if test $? != 0; then
       AC_MSG_ERROR("Error in sollya compilation")
@@ -2941,8 +2941,8 @@ if test "x$optlevel" != x; then
   CFLAGS+=" -O$optlevel "
 else
   if test "x$panda_OPT" = xyes; then
-    CXXFLAGS+=" -Ofast -march=native -mtune=native "
-    CFLAGS+=" -Ofast -march=native -mtune=native "
+    CXXFLAGS+=" -Ofast"
+    CFLAGS+=" -Ofast"
   else
     if test "x$panda_WERROR" = xyes; then
       CXXFLAGS+=" -O1 "
diff --git a/ext/libfplll-4.0.3/src/dpe.h b/ext/libfplll-4.0.3/src/dpe.h
index 9bcc8f1dd..aa0d6be3f 100644
--- a/ext/libfplll-4.0.3/src/dpe.h
+++ b/ext/libfplll-4.0.3/src/dpe.h
@@ -154,7 +154,7 @@ dpe_abs (dpe_t x, const dpe_t y)
 static void
 dpe_normalize (dpe_t x)
 {
- if (DPE_UNLIKELY (DPE_MANT(x) == 0.0 || finite (DPE_MANT(x)) == 0))
+ if (DPE_UNLIKELY (DPE_MANT(x) == 0.0 || isfinite (DPE_MANT(x)) == 0))
    {
      if (DPE_MANT(x) == 0.0)
        DPE_EXP(x) = DPE_EXPMIN;
diff --git a/ext/libfplll-4.0.3/src/util.cpp b/ext/libfplll-4.0.3/src/util.cpp
index 55abb8267..eaa30f2ed 100644
--- a/ext/libfplll-4.0.3/src/util.cpp
+++ b/ext/libfplll-4.0.3/src/util.cpp
@@ -152,7 +152,7 @@ ostream& operator<<(ostream& os, const Z_NR<mpz_t>& x) {
 template<>
 ostream& operator<<(ostream& os, const FP_NR<dpe_t>& x) {
   double m = DPE_MANT(x.getData());
-  if (!finite(m))
+  if (!isfinite(m))
     os << m;
   else {
     double mm = DPE_EXP(x.getData()) * log10(2.0);
diff --git a/src/bambu.am b/src/bambu.am
index 168f47b70..801c67206 100644
--- a/src/bambu.am
+++ b/src/bambu.am
@@ -203,6 +203,6 @@ bambu_LDADD = lib_bambu.la @PTHREAD_HACK@
 
 bambu_LDFLAGS = $(AM_LDFLAGS)
 # The following is necessary to allow static self-registration of Factory derived classes
-bambu_LDFLAGS += -Wl,--whole-archive,$(top_builddir)/src/HLS/.libs/lib_module_generator.a,--no-whole-archive
+bambu_LDFLAGS += -Wl,-force_load,$(top_builddir)/src/HLS/.libs/lib_module_generator.a
 
 
diff --git a/src/eucalyptus.am b/src/eucalyptus.am
index 793d53c36..761dc04aa 100644
--- a/src/eucalyptus.am
+++ b/src/eucalyptus.am
@@ -105,7 +105,7 @@ eucalyptus_LDFLAGS = $(AM_LDFLAGS)
 
 if BUILD_LIB_HLS
    # The following is necessary to allow static self-registration of Factory derived classes
-   eucalyptus_LDFLAGS += -Wl,--whole-archive,$(top_builddir)/src/HLS/.libs/lib_module_generator.a,--no-whole-archive
+   eucalyptus_LDFLAGS += -Wl,-force_load,$(top_builddir)/src/HLS/.libs/lib_module_generator.a
 endif
 
 PRJ_DOC += eucalyptus.doc

However, it fails when compiling some libhls code (which is beyond my expertise):

Assertion failed: (getActiveBits() <= 64 && "Too many bits for uint64_t"), function getZExtValue, file APInt.h, line 1634.
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/homebrew/opt/llvm@12/bin/clang -D__NO_INLINE__ -D_FORTIFY_SOURCE=0 -mllvm -inline-threshold=10000 -MT libhls_cdiv_clang12_a-divdc3.o -MD -MP -MF .deps/libhls_cdiv_clang12_a-divdc3.Tpo -m32 -mno-sse2 -c -fplugin=../../../etc/clang_plugin/../clang_plugin/clang12_plugin_dumpGimpleSSA.so -mllvm -panda-outputdir=/tmp/panda-temp-2816-940e-7b18-eea4/ -mllvm -panda-infile=/Users/drichmond/Research/repositories/git/PandA-bambu/build/etc/libbambu/soft-fp/../../../../etc/libbambu/soft-fp/divdc3.c -mllvm -panda-cost-table=store_expr|32=10,load_expr|32=20,nop_expr|32=10,mult_expr|1=0.53300000000000003,mult_expr|8=2.2559999999999998,mult_expr|16=3.778,mult_expr|32=5.4339999999999993,mult_expr|64=8.2169999999999987,plus_expr|1=0.53300000000000003,plus_expr|8=1.002,plus_expr|16=1.109,plus_expr|32=1.321,plus_expr|64=1.7450000000000001,trunc_div_expr|1=0.53300000000000003,trunc_div_expr|8=8.2609999999999992,trunc_div_expr|16=23.864000000000001,trunc_div_expr|32=55.195,trunc_div_expr|64=153.52799999999999,trunc_mod_expr|1=0.53300000000000003,trunc_mod_expr|8=9.0609999999999999,trunc_mod_expr|16=21.321000000000002,trunc_mod_expr|32=54.350999999999999,trunc_mod_expr|64=154.405,lshift_expr|1=0.53300000000000003,lshift_expr|8=1.0349999999999999,lshift_expr|16=1.194,lshift_expr|32=1.621,lshift_expr|64=1.8580000000000001,rshift_expr|1=0.53300000000000003,rshift_expr|8=1.018,rshift_expr|16=1.3089999999999999,rshift_expr|32=1.702,rshift_expr|64=1.9019999999999999,bit_and_expr|1=0.53300000000000003,bit_and_expr|8=0.496,bit_and_expr|16=0.504,bit_and_expr|32=0.56899999999999995,bit_and_expr|64=0.58299999999999996,bit_ior_expr|1=0.53300000000000003,bit_ior_expr|8=0.496,bit_ior_expr|16=0.504,bit_ior_expr|32=0.56899999999999995,bit_ior_expr|64=0.58299999999999996,bit_xor_expr|1=0.45000000000000001,bit_xor_expr|8=0.52800000000000002,bit_xor_expr|16=0.59499999999999997,bit_xor_expr|32=0.56000000000000005,bit_xor_expr|64=0.65700000000000003,cond_expr|1=0.58499999999999996,cond_expr|8=1.0820000000000001,cond_expr|16=1.1970000000000001,cond_expr|32=1.536,cond_expr|64=1.7130000000000001,Fmult_expr|32=8.5489999999999995,Fmult_expr|64=20,Fplus_expr|32=20,Fplus_expr|64=30,Frdiv_expr|32=60,Frdiv_expr|64=110 -emit-llvm -o /tmp/panda-temp-2816-940e-7b18-eea4//run-fac9-119b-9e99-ec4d.o -O3 -fno-builtin-bcmp -fno-builtin-memcpy -fno-builtin-memmove -fno-builtin-memset -fno-slp-vectorize -fno-stack-protector -fno-vectorize -fwrapv -DHAVE_CONFIG_H -D_FLT_NO_DENORMALS -Wuninitialized -I /Users/drichmond/Research/repositories/git/PandA-bambu/build/etc/libbambu/soft-fp/. -I /Users/drichmond/Research/repositories/git/PandA-bambu/build/etc/libbambu/soft-fp/../../../../etc/libbambu/soft-fp -I /Users/drichmond/Research/repositories/git/PandA-bambu/build/etc/libbambu/soft-fp/../../.. -I /opt/homebrew/include/ -I /Users/drichmond/Research/repositories/git/PandA-bambu/build/etc/libbambu/soft-fp/../../../../etc/libbambu -I /opt/homebrew/Cellar/boost/1.80.0//include /Users/drichmond/Research/repositories/git/PandA-bambu/build/etc/libbambu/soft-fp/../../../../etc/libbambu/soft-fp/divdc3.c
1.	<eof> parser at end of file
2.	Per-module optimization passes
3.	Running pass 'clang12_plugin_dumpGimpleSSA' on module '/Users/drichmond/Research/repositories/git/PandA-bambu/build/etc/libbambu/soft-fp/../../../../etc/libbambu/soft-fp/divdc3.c'.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.dylib                   0x000000010ae10e58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  libLLVM.dylib                   0x000000010ae10870 llvm::sys::CleanupOnSignal(unsigned long) + 236
2  libLLVM.dylib                   0x000000010ad8322c (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 120
3  libLLVM.dylib                   0x000000010ad83408 CrashRecoverySignalHandler(int) + 152
4  libsystem_platform.dylib        0x00000001aac534a4 _sigtramp + 56
5  libsystem_pthread.dylib         0x00000001aac3bee0 pthread_kill + 288
6  libsystem_c.dylib               0x00000001aab76340 abort + 168
7  libsystem_c.dylib               0x00000001aab75754 err + 0
8  clang12_plugin_dumpGimpleSSA.so 0x0000000100e21cc8 llvm::DumpGimpleRaw::TYPE_MAX_VALUE(void const*) + 1344
9  clang12_plugin_dumpGimpleSSA.so 0x0000000100e310b4 llvm::DumpGimpleRaw::dequeue_and_serialize() + 3580
10 clang12_plugin_dumpGimpleSSA.so 0x0000000100e32be4 llvm::DumpGimpleRaw::SerializeGimpleGlobalTreeNode(void const*) + 276
11 clang12_plugin_dumpGimpleSSA.so 0x0000000100e39388 llvm::DumpGimpleRaw::runOnModule(llvm::Module&, llvm::ModulePass*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 692
12 clang12_plugin_dumpGimpleSSA.so 0x0000000100e0e544 llvm::clang12_plugin_dumpGimpleSSA<false>::runOnModule(llvm::Module&) + 1508
13 libLLVM.dylib                   0x000000010af02008 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 572
14 libclang-cpp.dylib              0x0000000103e29904 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) + 7536
15 libclang-cpp.dylib              0x000000010400cf08 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 816
16 libclang-cpp.dylib              0x00000001034ef134 clang::ParseAST(clang::Sema&, bool, bool) + 492
17 libclang-cpp.dylib              0x00000001044aaa14 clang::FrontendAction::Execute() + 96
18 libclang-cpp.dylib              0x000000010446ed84 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1248
19 libclang-cpp.dylib              0x00000001044ed2a4 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 920
20 clang-12                        0x0000000100afd028 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1484
21 clang-12                        0x0000000100afb23c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 556
22 libclang-cpp.dylib              0x000000010429732c void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const::$_1>(long) + 28
23 libLLVM.dylib                   0x000000010ad8317c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 248
24 libclang-cpp.dylib              0x0000000104296a10 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const + 212
25 libclang-cpp.dylib              0x0000000104278d78 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const + 492
26 libclang-cpp.dylib              0x0000000104278f24 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) const + 88
27 libclang-cpp.dylib              0x00000001042861e8 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) + 184
28 clang-12                        0x0000000100afa9f0 main + 6356
29 dyld                            0x0000000100b5908c start + 520
clang-12: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Homebrew clang version 12.0.1
Target: arm-apple-darwin21.6.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm@12/bin
clang-12: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /var/folders/x3/lv94mmvd6lb2g52jfjb1v8mr0000gn/T/divdc3-6d7acd.c
clang-12: note: diagnostic msg: /var/folders/x3/lv94mmvd6lb2g52jfjb1v8mr0000gn/T/divdc3-6d7acd.sh
clang-12: note: diagnostic msg: Crash backtrace is located in
clang-12: note: diagnostic msg: /Users/drichmond/Library/Logs/DiagnosticReports/clang-12_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang-12: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang-12: note: diagnostic msg: 

********************
error -> Front-end compiler returns an error during compilation 2

make[4]: *** [libhls_cdiv_clang12_a-divdc3.o] Error 11
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Someone else is welcome to take it up from here.

Is it possible to add support for Clang 13? The error is above is solved in Clang 13, but not 12.

@Ansaya is working on clang13 right now. I hope he is fixing the issue in a while.
Fabrizio

Rad, great to hear!

I believe this will enable M2 compilation

Clang13 and Clang16 are now supported. Check dev/panda branch.