From 9b3d83359cc3f55049b5a48cb736a9a43bf04afc Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:35:46 +0100 Subject: - passes/techmap/dfflibmap.cc, passes/fsm/fsm_recode.cc, passes/cmds/select.cc: #include for errno, use c++-style includes. --- passes/cmds/select.cc | 1 + passes/fsm/fsm_recode.cc | 3 ++- passes/techmap/dfflibmap.cc | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/passes/cmds/select.cc b/passes/cmds/select.cc index 3a886b1c..59f936b0 100644 --- a/passes/cmds/select.cc +++ b/passes/cmds/select.cc @@ -23,6 +23,7 @@ #include "kernel/log.h" #include #include +#include using RTLIL::id2cstr; diff --git a/passes/fsm/fsm_recode.cc b/passes/fsm/fsm_recode.cc index 5a4e091c..b0228796 100644 --- a/passes/fsm/fsm_recode.cc +++ b/passes/fsm/fsm_recode.cc @@ -23,8 +23,9 @@ #include "kernel/consteval.h" #include "kernel/celltypes.h" #include "fsmdata.h" -#include "math.h" +#include #include +#include static void fm_set_fsm_print(RTLIL::Cell *cell, RTLIL::Module *module, FsmData &fsm_data, const char *prefix, FILE *f) { diff --git a/passes/techmap/dfflibmap.cc b/passes/techmap/dfflibmap.cc index fd5fa86e..4bf73358 100644 --- a/passes/techmap/dfflibmap.cc +++ b/passes/techmap/dfflibmap.cc @@ -21,6 +21,7 @@ #include "kernel/log.h" #include "libparse.h" #include +#include using namespace PASS_DFFLIBMAP; -- cgit v1.2.3 From f7c2cf6fe29fc452385c37f015e03febf650ecd3 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:35:53 +0100 Subject: - passes/abc/abc.cc: #include for errno; use POSIX getcwd() for portability (get_current_dir_name() does not exist on BSD). --- passes/abc/abc.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index 2829e660..24a634f6 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include #include "blifparse.h" @@ -973,7 +974,11 @@ struct AbcPass : public Pass { int lut_mode = 0; size_t argidx; - char *pwd = get_current_dir_name(); + char pwd [PATH_MAX]; + if (!getcwd(pwd, sizeof(pwd))) { + log_cmd_error("getcwd failed: %s\n", strerror(errno)); + log_abort(); + } for (argidx = 1; argidx < args.size(); argidx++) { std::string arg = args[argidx]; if (arg == "-exe" && argidx+1 < args.size()) { @@ -1020,7 +1025,6 @@ struct AbcPass : public Pass { } break; } - free(pwd); extra_args(args, argidx, design); if (lut_mode != 0 && !liberty_file.empty()) -- cgit v1.2.3 From 40e0b79495195eaa2bc6bf32e8d52a5aa956a2b4 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:35:59 +0100 Subject: - libs/ezsat/ezsat.cc: need to #include or math.h for math functions. --- libs/ezsat/ezsat.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/ezsat/ezsat.cc b/libs/ezsat/ezsat.cc index fb3d2499..6da363fc 100644 --- a/libs/ezsat/ezsat.cc +++ b/libs/ezsat/ezsat.cc @@ -19,10 +19,11 @@ #include "ezsat.h" +#include #include +#include #include -#include const int ezSAT::TRUE = 1; const int ezSAT::FALSE = 2; -- cgit v1.2.3 From 8111938e962b60294e51d5f0d10b6d1855bc1b91 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:36:07 +0100 Subject: - kernel/log.h: add rusage()-based fallback for systems without clock_gettime(). --- kernel/log.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/log.h b/kernel/log.h index c4c03352..fbc3c1c3 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -23,6 +23,8 @@ #include "kernel/rtlil.h" #include #include +#include +#include #include extern std::vector log_files; @@ -65,9 +67,23 @@ struct PerformanceTimer } static int64_t query() { +#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) struct timespec ts; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); return int64_t(ts.tv_sec)*1000000000 + ts.tv_nsec; +#elif defined(RUSAGE_SELF) + struct rusage rusage; + int64_t t; + if (getrusage(RUSAGE_SELF, &rusage) == -1) { + log_cmd_error("getrusage failed!\n"); + log_abort(); + } + t = 1000000000ULL * (int64_t) rusage.ru_utime.tv_sec + (int64_t) rusage.ru_utime.tv_usec * 1000ULL; + t += 1000000000ULL * (int64_t) rusage.ru_stime.tv_sec + (int64_t) rusage.ru_stime.tv_usec * 1000ULL; + return t; +#else + #error Dont know how to measure per-process CPU time. Need alternative method (times()/clocks()/gettimeofday()?). +#endif } void reset() { -- cgit v1.2.3 From 6698d67d2416069ea728b879db67b6ea0582cce4 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:36:12 +0100 Subject: - kernel/driver.cc: need to #include or errno.h for errno. --- kernel/driver.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/driver.cc b/kernel/driver.cc index 00a61ec0..ce95cad4 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include -- cgit v1.2.3 From c056217e72ff1e2da1340f97ad3a76f3ed486841 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:36:23 +0100 Subject: - kernel/register.cc: need to #include or errno.h for errno. --- kernel/register.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/register.cc b/kernel/register.cc index ee14ffba..ab5cba11 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -23,6 +23,7 @@ #include #include #include +#include using namespace REGISTER_INTERN; #define MAX_REG_COUNT 1000 -- cgit v1.2.3 From f6579282d73aec055e2fc4ebebd1b6313da248fd Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:36:27 +0100 Subject: - frontends/vhdl2verilog/vhdl2verilog.cc: #include for errno; use POSIX getcwd() for portability. --- frontends/vhdl2verilog/vhdl2verilog.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontends/vhdl2verilog/vhdl2verilog.cc b/frontends/vhdl2verilog/vhdl2verilog.cc index 0467810e..d8568fe9 100644 --- a/frontends/vhdl2verilog/vhdl2verilog.cc +++ b/frontends/vhdl2verilog/vhdl2verilog.cc @@ -26,6 +26,7 @@ #include #include #include +#include struct Vhdl2verilogPass : public Pass { Vhdl2verilogPass() : Pass("vhdl2verilog", "importing VHDL designs using vhdl2verilog") { } @@ -93,9 +94,12 @@ struct Vhdl2verilogPass : public Pass { log_error("For some reason mkdtemp() failed!\n"); if (!out_file.empty() && out_file[0] != '/') { - char *pwd = get_current_dir_name(); + char pwd [PATH_MAX]; + if (!getcwd(pwd, sizeof(pwd))) { + log_cmd_error("getcwd failed: %s", strerror(errno)); + log_abort(); + } out_file = pwd + ("/" + out_file); - free(pwd); } FILE *f = fopen(stringf("%s/files.list", tempdir_name).c_str(), "wt"); @@ -104,9 +108,12 @@ struct Vhdl2verilogPass : public Pass { if (file.empty()) continue; if (file[0] != '/') { - char *pwd = get_current_dir_name(); + char pwd [PATH_MAX]; + if (!getcwd(pwd, sizeof(pwd))) { + log_cmd_error("getcwd failed: %s", strerror(errno)); + log_abort(); + } file = pwd + ("/" + file); - free(pwd); } fprintf(f, "%s\n", file.c_str()); log("Adding '%s' to the file list.\n", file.c_str()); -- cgit v1.2.3 From 9327d434d522f888609e5f4a42a6e06f01864e79 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:37:14 +0100 Subject: - README: fix typo in sed-command for minisat-include fix. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 385ee2c0..45febc2f 100644 --- a/README +++ b/README @@ -292,7 +292,7 @@ a recent version of gcc: This is a bug in the minisat header. It can be fixed by adding spaces before and after each occurrence of PRIi64 in the header file: - sudo sed -i 's/PRIi64/ & /' /usr/include/minisat/utils/Options.h + sudo sed -i -e 's/PRIi64/ & /' /usr/include/minisat/utils/Options.h Roadmap / Large-scale TODOs -- cgit v1.2.3 From 0fb044a58f7cc66364af3a0a53c8b5089e0149ad Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 14:38:01 +0100 Subject: - Makefile, kernel/posix_compatibility.h/.cc: provide POSIX.2008 fake implementation of open_memstream()/fmemopen() for pre-POSIX.2008 systems. - Makefile: OSX build rules (Apple's gcc and clang have no -rdynamic option and no librt). - Makefile: Generate debugger symbols and don't optimize for size in debug target (otherwise the debugger pretty hard to use). - Makefile: Reorder target concatenation in order to avoid use-before-built problems for source-include and linker dependencies. - Makefile: On OSX/macports, qmake-qt4 is named 'qmake' (the default Qt4 installation name, unless the distribution changes it). - Makefile: For OSX/Macports, we need to pass -I/opt/local/include and -L/opt/local/lib to give GNU libraries precedence over Apple's. - Makefile: Build a local minisat copy just like abc (to avoid dependency on broken/unmaintained distribution header files). - .gitignore: Ignore minisat directory. --- .gitignore | 1 + Makefile | 46 +++++++++++---- kernel/posix_compatibility.cc | 134 ++++++++++++++++++++++++++++++++++++++++++ kernel/posix_compatibility.h | 40 +++++++++++++ 4 files changed, 211 insertions(+), 10 deletions(-) create mode 100644 kernel/posix_compatibility.cc create mode 100644 kernel/posix_compatibility.h diff --git a/.gitignore b/.gitignore index f251d2b6..77d6e29e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /qtcreator.creator /qtcreator.creator.user /Makefile.conf +/minisat /abc /yosys /yosys-abc diff --git a/Makefile b/Makefile index a68ceccb..c0d43a2c 100644 --- a/Makefile +++ b/Makefile @@ -19,14 +19,24 @@ INSTALL_SUDO := OBJS = GENFILES = EXTRA_TARGETS = -TARGETS = yosys yosys-config +TARGETS = all: top-all -CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -MD -D_YOSYS_ -fPIC -LDFLAGS = -rdynamic -LDLIBS = -lstdc++ -lreadline -lm -ldl -lrt -QMAKE = qmake-qt4 +CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSYS_ -fPIC -include kernel/posix_compatibility.h +LDFLAGS = -I${DESTDIR}/lib +LDLIBS = -lstdc++ -lreadline -lm -ldl + +ifeq (Darwin,$(findstring Darwin,$(shell uname))) + # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': + CXXFLAGS += -I/opt/local/include + LDFLAGS += -L/opt/local/lib + QMAKE = qmake +else + LDFLAGS += -rdynamic + LDLIBS += -lrt + QMAKE = qmake-qt4 +endif YOSYS_VER := 0.2.0+ GIT_REV := $(shell git rev-parse --short HEAD || echo UNKOWN) @@ -41,16 +51,18 @@ OBJS = kernel/version_$(GIT_REV).o ABCREV = 2058c8ccea68 ABCPULL = 1 +MINISATREV = HEAD + -include Makefile.conf ifeq ($(CONFIG),clang-debug) CXX = clang -CXXFLAGS += -std=c++11 -Os +CXXFLAGS += -std=c++11 -g -O0 -Wall endif ifeq ($(CONFIG),gcc-debug) CXX = gcc -CXXFLAGS += -std=gnu++0x -Os +CXXFLAGS += -std=gnu++0x -g -O0 -Wall endif ifeq ($(CONFIG),release) @@ -70,8 +82,8 @@ CXXFLAGS += -pg -fno-inline LDFLAGS += -pg endif -ifeq ($(ENABLE_QT4),1) -TARGETS += yosys-svgviewer +ifeq ($(ENABLE_MINISAT),1) +TARGETS += yosys-minisat endif ifeq ($(ENABLE_ABC),1) @@ -85,7 +97,14 @@ CXXFLAGS += $(patsubst %,-I$(VERIFIC_DIR)/%,$(VERIFIC_COMPONENTS)) -D'VERIFIC_DI LDLIBS += $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VERIFIC_COMPONENTS)) endif -OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o +# Build yosys after minisat and abc (we need to access the local copies of the downloaded/installed header files). +TARGETS += yosys yosys-config + +ifeq ($(ENABLE_QT4),1) +TARGETS += yosys-svgviewer +endif + +OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o kernel/posix_compatibility.o OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o @@ -123,6 +142,13 @@ yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp cd libs/svgviewer && $(QMAKE) && make cp libs/svgviewer/svgviewer yosys-svgviewer +yosys-minisat: $(DESTDIR)/bin/minisat +$(DESTDIR)/bin/minisat: + test -d minisat || ( git clone https://github.com/niklasso/minisat.git minisat && sed -i -e 's/PRIi64/ & /' minisat/minisat/utils/Options.h ) + ( cd minisat && git checkout $(MINISATREV) ) + ( cd minisat && $(MAKE) prefix=$(DESTDIR) DESTDIR="" config install ) + @( cd minisat && echo "Installed minisat version `git describe --always --dirty` into $(DESTDIR)." ) + abc/abc-$(ABCREV): ifneq ($(ABCREV),default) if ( cd abc && hg identify; ) | grep -q +; then \ diff --git a/kernel/posix_compatibility.cc b/kernel/posix_compatibility.cc new file mode 100644 index 00000000..d3fb0087 --- /dev/null +++ b/kernel/posix_compatibility.cc @@ -0,0 +1,134 @@ +/* + * yosys -- Yosys Open SYnthesis Suite + * + * Copyright (C) 2012 Clifford Wolf + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/** + * POSIX.2008 fake implementation for pre-POSIX.2008 systems. (OSX, BSD, MINGW, CYGWIN, older Linux &c.) + */ + +#include +#include +#include +#include + +#if !(_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L) +typedef struct memstream { + off_t pos; + off_t size; + char * buffer; + char ** bufp; + size_t * sizep; + bool realloc; +} memstream_t; + +static int memstream_read (void * cookie, char * buf, int size) +{ + memstream_t * mem = (memstream_t *) cookie; + off_t available = mem->size - mem->pos; + if (available < 0) + available = 0; + if (size > available) + size = available; + memcpy(buf, mem->buffer + mem->pos, size); + mem->pos += size; + return size; +} + +static int memstream_write (void * cookie, const char * buf, int size) +{ + memstream_t * mem = (memstream_t *) cookie; + off_t available = mem->size - mem->pos; + if (size > available) { + if (mem->realloc) { + mem->buffer = (char *) realloc(mem->buffer, mem->pos + size + 1); + memset(mem->buffer + mem->size, 0, mem->pos + size + 1 - mem->size); + mem->size = mem->pos + size; + if (mem->bufp) + *(mem->bufp) = mem->buffer; + if (mem->sizep) + *(mem->sizep) = mem->size; + } else { + size = available; + } + } + memcpy(mem->buffer + mem->pos, buf, sizeof(char) * size); + mem->pos += size; + return size; +} + +static fpos_t memstream_seek (void * cookie, fpos_t offset, int whence) +{ + memstream_t * mem = (memstream_t *) cookie; + switch (whence) { + case SEEK_SET: + if (offset < 0) + goto error_inval; + mem->pos = offset; + return 0; + case SEEK_CUR: + if (mem->pos + offset < 0) + goto error_inval; + mem->pos += offset; + return 0; + case SEEK_END: + if (mem->size + offset < 0) + goto error_inval; + mem->pos = mem->size + offset; + break; + default: + goto error_inval; + } + return mem->pos; +error_inval: + errno = EINVAL; + return -1; +} + +static int memstream_close (void * cookie) +{ + memstream_t * mem = (memstream_t *) cookie; + if (mem->bufp) + *(mem->bufp) = mem->buffer; + if (mem->sizep) + *(mem->sizep) = mem->size; + free(cookie); + return 0; +} + +FILE * fmemopen (void * buf, size_t size, const char * mode) +{ + memstream_t * mem = (memstream_t *) malloc(sizeof(memstream_t)); + memset(mem, 0, sizeof(memstream_t)); + mem->size = size; + mem->buffer = (char *) buf; + (void) mode; + return funopen(mem, memstream_read, memstream_write, memstream_seek, memstream_close); +} + +FILE * open_memstream (char ** bufp, size_t * sizep) +{ + memstream_t * mem = (memstream_t *) malloc(sizeof(memstream_t)); + memset(mem, 0, sizeof(memstream_t)); + mem->bufp = bufp; + mem->sizep = sizep; + mem->realloc = true; + return funopen(mem, memstream_read, memstream_write, memstream_seek, memstream_close); +} + +#endif + diff --git a/kernel/posix_compatibility.h b/kernel/posix_compatibility.h new file mode 100644 index 00000000..d6eaade0 --- /dev/null +++ b/kernel/posix_compatibility.h @@ -0,0 +1,40 @@ +/* + * yosys -- Yosys Open SYnthesis Suite + * + * Copyright (C) 2012 Clifford Wolf + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifndef POSIX_COMPATIBILITY_H +#define POSIX_COMPATIBILITY_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#include +#include + +#if !(_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L) +FILE * open_memstream (char ** bufp, size_t * sizep); +FILE * fmemopen (void * buf, size_t size, const char * mode); +#endif + +#if defined(__cplusplus) +} +#endif + +#endif + -- cgit v1.2.3 From 8a0216bd9f81faf45e1ff463edcc6d82dfa20565 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 15:02:58 +0100 Subject: - libs/ezsat/ezminisat.cc: use POSIX.2001 sigaction() instead on non-portable signal(). --- libs/ezsat/ezminisat.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/ezsat/ezminisat.cc b/libs/ezsat/ezminisat.cc index d488a906..92f56b00 100644 --- a/libs/ezsat/ezminisat.cc +++ b/libs/ezsat/ezminisat.cc @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -170,14 +170,18 @@ contradiction: #endif } - sighandler_t old_alarm_sighandler = NULL; + struct sigaction sig_action; + struct sigaction old_sig_action; int old_alarm_timeout = 0; if (solverTimeout > 0) { + sig_action.sa_handler = alarmHandler; + sig_action.sa_mask = 0; + sig_action.sa_flags = 0; alarmHandlerThis = this; alarmHandlerTimeout = clock() + solverTimeout*CLOCKS_PER_SEC; old_alarm_timeout = alarm(0); - old_alarm_sighandler = signal(SIGALRM, alarmHandler); + sigaction(SIGALRM, &sig_action, &old_sig_action); alarm(1); } @@ -187,7 +191,7 @@ contradiction: if (alarmHandlerTimeout == 0) solverTimoutStatus = true; alarm(0); - signal(SIGALRM, old_alarm_sighandler); + sigaction(SIGALRM, &old_sig_action, NULL); alarm(old_alarm_timeout); } -- cgit v1.2.3 From 63ca8d3fe4273d9e07233f94037a63659d6d18e4 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 15:07:37 +0100 Subject: - Makefile, techlibs/common/Makefile.inc: call GNU sed instead of BSD sed on OSX (for extended regular expressions). --- Makefile | 6 ++++-- techlibs/common/Makefile.inc | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c0d43a2c..7bd8a450 100644 --- a/Makefile +++ b/Makefile @@ -32,10 +32,12 @@ ifeq (Darwin,$(findstring Darwin,$(shell uname))) CXXFLAGS += -I/opt/local/include LDFLAGS += -L/opt/local/lib QMAKE = qmake + SED = gsed else LDFLAGS += -rdynamic LDLIBS += -lrt QMAKE = qmake-qt4 + SED = sed endif YOSYS_VER := 0.2.0+ @@ -134,7 +136,7 @@ kernel/version_$(GIT_REV).cc: Makefile echo "extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys $(YOSYS_VER) (git sha1 $(GIT_REV))\";" > kernel/version_$(GIT_REV).cc yosys-config: yosys-config.in - sed -e 's,@CXX@,$(CXX),;' -e 's,@CXXFLAGS@,$(CXXFLAGS),;' -e 's,@LDFLAGS@,$(LDFLAGS),;' -e 's,@LDLIBS@,$(LDLIBS),;' \ + $(SED) -e 's,@CXX@,$(CXX),;' -e 's,@CXXFLAGS@,$(CXXFLAGS),;' -e 's,@LDFLAGS@,$(LDFLAGS),;' -e 's,@LDLIBS@,$(LDLIBS),;' \ -e 's,@BINDIR@,$(DESTDIR)/bin,;' -e 's,@DATDIR@,$(DESTDIR)/share/yosys,;' < yosys-config.in > yosys-config chmod +x yosys-config @@ -144,7 +146,7 @@ yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp yosys-minisat: $(DESTDIR)/bin/minisat $(DESTDIR)/bin/minisat: - test -d minisat || ( git clone https://github.com/niklasso/minisat.git minisat && sed -i -e 's/PRIi64/ & /' minisat/minisat/utils/Options.h ) + test -d minisat || ( git clone https://github.com/niklasso/minisat.git minisat && $(SED) -i -e 's/PRIi64/ & /' minisat/minisat/utils/Options.h ) ( cd minisat && git checkout $(MINISATREV) ) ( cd minisat && $(MAKE) prefix=$(DESTDIR) DESTDIR="" config install ) @( cd minisat && echo "Installed minisat version `git describe --always --dirty` into $(DESTDIR)." ) diff --git a/techlibs/common/Makefile.inc b/techlibs/common/Makefile.inc index 6d94d5c9..c68b13f6 100644 --- a/techlibs/common/Makefile.inc +++ b/techlibs/common/Makefile.inc @@ -2,7 +2,7 @@ EXTRA_TARGETS += techlibs/common/blackbox.v techlibs/common/blackbox.v: techlibs/common/blackbox.sed techlibs/common/simlib.v techlibs/common/simcells.v - cat techlibs/common/simlib.v techlibs/common/simcells.v | sed -rf techlibs/common/blackbox.sed > techlibs/common/blackbox.v.new + cat techlibs/common/simlib.v techlibs/common/simcells.v | $(SED) -rf techlibs/common/blackbox.sed > techlibs/common/blackbox.v.new mv techlibs/common/blackbox.v.new techlibs/common/blackbox.v EXTRA_TARGETS += share/simlib.v share/simcells.v share/blackbox.v share/pmux2mux.v -- cgit v1.2.3 From 2f2e76ac68dc8da8618ebbf602e2c871f5d4b1b8 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 19:50:02 +0100 Subject: - frontends/vhdl2verilog/vhdl2verilog.cc, passes/abc/abc.cc: #include for PATH_MAX. --- frontends/vhdl2verilog/vhdl2verilog.cc | 1 + passes/abc/abc.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/frontends/vhdl2verilog/vhdl2verilog.cc b/frontends/vhdl2verilog/vhdl2verilog.cc index d8568fe9..83035d32 100644 --- a/frontends/vhdl2verilog/vhdl2verilog.cc +++ b/frontends/vhdl2verilog/vhdl2verilog.cc @@ -27,6 +27,7 @@ #include #include #include +#include struct Vhdl2verilogPass : public Pass { Vhdl2verilogPass() : Pass("vhdl2verilog", "importing VHDL designs using vhdl2verilog") { } diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index 24a634f6..286b750c 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -45,6 +45,7 @@ #include #include #include +#include #include "blifparse.h" -- cgit v1.2.3 From 4d56e23e318a6739ec06ce74d81dfa1d940aef0f Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:06:46 +0100 Subject: - Makefile: export PATH=${DESTDIR}/bin:$(PATH) and (DY)LD_LIBRARY_PATH, to make sure our local copies of built executables and libraries are used. - Makefile: use find expression in target 'yosys-svgviewer' to find svgviewer binary (qmake will build into .app package on OSX). - Makefile: make 'test' target dependent on $(TARGETS) and $(EXTRA_TARGETS) to make sure that minisat is built. --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7bd8a450..82c09d05 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,17 @@ CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSY LDFLAGS = -I${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl +export PATH := ${DESTDIR}/bin:$(PATH) + ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': + export DYLD_LIBRARY_PATH := ${DESTDIR}/lib:$(DYLD_LIBRARY_PATH) CXXFLAGS += -I/opt/local/include LDFLAGS += -L/opt/local/lib QMAKE = qmake SED = gsed else + export LD_LIBRARY_PATH := ${DESTDIR}/lib:$(LD_LIBRARY_PATH) LDFLAGS += -rdynamic LDLIBS += -lrt QMAKE = qmake-qt4 @@ -142,7 +146,7 @@ yosys-config: yosys-config.in yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp cd libs/svgviewer && $(QMAKE) && make - cp libs/svgviewer/svgviewer yosys-svgviewer + cp `find libs/svgviewer -name svgviewer -type f` yosys-svgviewer yosys-minisat: $(DESTDIR)/bin/minisat $(DESTDIR)/bin/minisat: @@ -172,7 +176,7 @@ endif yosys-abc: abc/abc-$(ABCREV) cp abc/abc-$(ABCREV) yosys-abc -test: yosys +test: $(TARGETS) $(EXTRA_TARGETS) cd tests/simple && bash run-test.sh cd tests/hana && bash run-test.sh cd tests/asicworld && bash run-test.sh -- cgit v1.2.3 From 113f129b348c48fff67242fe65906b3821ae7bd4 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:12:20 +0100 Subject: - Makefile: fix typo in LDFLAGS: obviously -L, not -I is required here --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 82c09d05..849860a3 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ TARGETS = all: top-all CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSYS_ -fPIC -include kernel/posix_compatibility.h -LDFLAGS = -I${DESTDIR}/lib +LDFLAGS = -L${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl export PATH := ${DESTDIR}/bin:$(PATH) -- cgit v1.2.3 From d091be401140088431ac2c1bf2bc97415e37c9ff Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:23:55 +0100 Subject: - libs/ezsat/ezminisat.cc: use sigemptyset() to clear sig_action.sa_mask; use SA_RESTART flag for improved robustness of code that is not signal-aware. --- libs/ezsat/ezminisat.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ezsat/ezminisat.cc b/libs/ezsat/ezminisat.cc index 92f56b00..4677f68b 100644 --- a/libs/ezsat/ezminisat.cc +++ b/libs/ezsat/ezminisat.cc @@ -176,8 +176,8 @@ contradiction: if (solverTimeout > 0) { sig_action.sa_handler = alarmHandler; - sig_action.sa_mask = 0; - sig_action.sa_flags = 0; + sigemptyset(&sig_action.sa_mask); + sig_action.sa_flags = SA_RESTART; alarmHandlerThis = this; alarmHandlerTimeout = clock() + solverTimeout*CLOCKS_PER_SEC; old_alarm_timeout = alarm(0); -- cgit v1.2.3 From 876c016904989bc54eafada1363e31f291854542 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:27:39 +0100 Subject: - Makefile: include $(PWD) in PATH, since 'make test' can happen before 'make install'. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 849860a3..ce9a99bc 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSY LDFLAGS = -L${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl -export PATH := ${DESTDIR}/bin:$(PATH) +export PATH := $(PWD):$(DESTDIR)/bin:$(PATH) ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': -- cgit v1.2.3 From 707b46956e7de08ae44ec1d8812fe0393e60457b Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Tue, 11 Mar 2014 14:06:41 +0100 Subject: - passes/techmap/Makefile.inc: POSIX 'od' has no '-w' option. Use '-An' instead. Replace awk by simple shell commands for portability. --- passes/techmap/Makefile.inc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/passes/techmap/Makefile.inc b/passes/techmap/Makefile.inc index ae1ebbb5..b83ab849 100644 --- a/passes/techmap/Makefile.inc +++ b/passes/techmap/Makefile.inc @@ -10,10 +10,12 @@ OBJS += passes/techmap/extract.o GENFILES += passes/techmap/stdcells.inc passes/techmap/stdcells.inc: techlibs/common/stdcells.v - echo "// autogenerated from $<" > $@.new - od -v -td1 -w1 $< | awk 'BEGIN { print "static char stdcells_code[] = {"; } $$2 != "" { print $$2 ","; } \ - END { print 0 "};"; }' | fmt >> $@.new - mv $@.new $@ + echo "// autogenerated from $<\n" > $@.new + echo "static char stdcells_code[] = {" >> $@.new + for c in `od -v -td1 -An $<` ; do echo " $$c," >> $@.new ; done + echo " 0 };" >> $@.new + fmt $@.new > $@ + rm -f $@.new passes/techmap/techmap.o: passes/techmap/stdcells.inc -- cgit v1.2.3 From 59d68e158281983c6b18914fb29c09b130552479 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Tue, 11 Mar 2014 19:39:01 +0100 Subject: - Makefile: resolve merge conflict. --- Makefile | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index abb473ba..5f40b594 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,22 @@ TARGETS = yosys yosys-config all: top-all -CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -MD -D_YOSYS_ -fPIC -LDFLAGS = -rdynamic -LDLIBS = -lstdc++ -lreadline -lm -ldl -lrt -QMAKE = qmake-qt4 -SED = sed +CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSYS_ -fPIC -include kernel/posix_compatibility.h +LDFLAGS = -I${DESTDIR}/lib +LDLIBS = -lstdc++ -lreadline -lm -ldl + +ifeq (Darwin,$(findstring Darwin,$(shell uname))) + # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': + CXXFLAGS += -I/opt/local/include + LDFLAGS += -L/opt/local/lib + QMAKE = qmake + SED = gsed +else + LDFLAGS += -rdynamic + LDLIBS += -lrt + QMAKE = qmake-qt4 + SED = sed +endif YOSYS_VER := 0.2.0+ GIT_REV := $(shell git rev-parse --short HEAD || echo UNKOWN) @@ -124,6 +135,13 @@ yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp cd libs/svgviewer && $(QMAKE) && make cp libs/svgviewer/svgviewer yosys-svgviewer +yosys-minisat: $(DESTDIR)/bin/minisat +$(DESTDIR)/bin/minisat: + test -d minisat || ( git clone https://github.com/niklasso/minisat.git minisat && $(SED) -i -e 's/PRIi64/ & /' minisat/minisat/utils/Options.h ) + ( cd minisat && git checkout $(MINISATREV) ) + ( cd minisat && $(MAKE) prefix=$(DESTDIR) DESTDIR="" config install ) + @( cd minisat && echo "Installed minisat version `git describe --always --dirty` into $(DESTDIR)." ) + abc/abc-$(ABCREV): ifneq ($(ABCREV),default) if ( cd abc && hg identify; ) | grep -q +; then \ -- cgit v1.2.3 From 4958559456c849811f213cb1b9e2beea61916e3c Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:06:46 +0100 Subject: - Makefile: export PATH=${DESTDIR}/bin:$(PATH) and (DY)LD_LIBRARY_PATH, to make sure our local copies of built executables and libraries are used. - Makefile: use find expression in target 'yosys-svgviewer' to find svgviewer binary (qmake will build into .app package on OSX). - Makefile: make 'test' target dependent on $(TARGETS) and $(EXTRA_TARGETS) to make sure that minisat is built. --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5f40b594..ad68ee1e 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,17 @@ CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSY LDFLAGS = -I${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl +export PATH := ${DESTDIR}/bin:$(PATH) + ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': + export DYLD_LIBRARY_PATH := ${DESTDIR}/lib:$(DYLD_LIBRARY_PATH) CXXFLAGS += -I/opt/local/include LDFLAGS += -L/opt/local/lib QMAKE = qmake SED = gsed else + export LD_LIBRARY_PATH := ${DESTDIR}/lib:$(LD_LIBRARY_PATH) LDFLAGS += -rdynamic LDLIBS += -lrt QMAKE = qmake-qt4 @@ -133,7 +137,7 @@ yosys-config: yosys-config.in yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp cd libs/svgviewer && $(QMAKE) && make - cp libs/svgviewer/svgviewer yosys-svgviewer + cp `find libs/svgviewer -name svgviewer -type f` yosys-svgviewer yosys-minisat: $(DESTDIR)/bin/minisat $(DESTDIR)/bin/minisat: @@ -163,7 +167,7 @@ endif yosys-abc: abc/abc-$(ABCREV) cp abc/abc-$(ABCREV) yosys-abc -test: yosys +test: $(TARGETS) $(EXTRA_TARGETS) cd tests/simple && bash run-test.sh cd tests/hana && bash run-test.sh cd tests/asicworld && bash run-test.sh -- cgit v1.2.3 From 4d56fbc150e5dcdefb1709d82aee91c9bb0d1227 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:12:20 +0100 Subject: - Makefile: fix typo in LDFLAGS: obviously -L, not -I is required here --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ad68ee1e..75a8f42b 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ TARGETS = yosys yosys-config all: top-all CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSYS_ -fPIC -include kernel/posix_compatibility.h -LDFLAGS = -I${DESTDIR}/lib +LDFLAGS = -L${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl export PATH := ${DESTDIR}/bin:$(PATH) -- cgit v1.2.3 From c17ee0f6dd5bb6e53ff0bf6da4650972323fc82d Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:27:39 +0100 Subject: - Makefile: include $(PWD) in PATH, since 'make test' can happen before 'make install'. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 75a8f42b..9f888c86 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSY LDFLAGS = -L${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl -export PATH := ${DESTDIR}/bin:$(PATH) +export PATH := $(PWD):$(DESTDIR)/bin:$(PATH) ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': -- cgit v1.2.3 From 59239f65dda58980c5b20a4b4723cd725e740fda Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Tue, 11 Mar 2014 22:00:49 +0100 Subject: - Makefile: don't add '-g' after '-ggdb' to CXXFLAGS --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ce9a99bc..c1c81b8e 100644 --- a/Makefile +++ b/Makefile @@ -63,12 +63,12 @@ MINISATREV = HEAD ifeq ($(CONFIG),clang-debug) CXX = clang -CXXFLAGS += -std=c++11 -g -O0 -Wall +CXXFLAGS += -std=c++11 -O0 -Wall endif ifeq ($(CONFIG),gcc-debug) CXX = gcc -CXXFLAGS += -std=gnu++0x -g -O0 -Wall +CXXFLAGS += -std=gnu++0x -O0 -Wall endif ifeq ($(CONFIG),release) -- cgit v1.2.3 From 8f3fa094817ec2c7df4253c690b5ccdb50a5b7d8 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Tue, 11 Mar 2014 19:39:01 +0100 Subject: - Makefile: resolve merge conflict. --- Makefile | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 73051e52..8da8b4c5 100644 --- a/Makefile +++ b/Makefile @@ -22,11 +22,22 @@ TARGETS = yosys yosys-config all: top-all -CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -MD -D_YOSYS_ -fPIC -LDFLAGS = -rdynamic -LDLIBS = -lstdc++ -lreadline -lm -ldl -lrt -QMAKE = qmake-qt4 -SED = sed +CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSYS_ -fPIC -include kernel/posix_compatibility.h +LDFLAGS = -I${DESTDIR}/lib +LDLIBS = -lstdc++ -lreadline -lm -ldl + +ifeq (Darwin,$(findstring Darwin,$(shell uname))) + # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': + CXXFLAGS += -I/opt/local/include + LDFLAGS += -L/opt/local/lib + QMAKE = qmake + SED = gsed +else + LDFLAGS += -rdynamic + LDLIBS += -lrt + QMAKE = qmake-qt4 + SED = sed +endif YOSYS_VER := 0.2.0+ GIT_REV := $(shell git rev-parse --short HEAD || echo UNKOWN) @@ -123,6 +134,13 @@ yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp cd libs/svgviewer && $(QMAKE) && make cp libs/svgviewer/svgviewer yosys-svgviewer +yosys-minisat: $(DESTDIR)/bin/minisat +$(DESTDIR)/bin/minisat: + test -d minisat || ( git clone https://github.com/niklasso/minisat.git minisat && $(SED) -i -e 's/PRIi64/ & /' minisat/minisat/utils/Options.h ) + ( cd minisat && git checkout $(MINISATREV) ) + ( cd minisat && $(MAKE) prefix=$(DESTDIR) DESTDIR="" config install ) + @( cd minisat && echo "Installed minisat version `git describe --always --dirty` into $(DESTDIR)." ) + abc/abc-$(ABCREV): ifneq ($(ABCREV),default) if ( cd abc && hg identify; ) | grep -q +; then \ -- cgit v1.2.3 From 94bc11f0216010e54a8a4dd1fd390af97181f627 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:06:46 +0100 Subject: - Makefile: export PATH=${DESTDIR}/bin:$(PATH) and (DY)LD_LIBRARY_PATH, to make sure our local copies of built executables and libraries are used. - Makefile: use find expression in target 'yosys-svgviewer' to find svgviewer binary (qmake will build into .app package on OSX). - Makefile: make 'test' target dependent on $(TARGETS) and $(EXTRA_TARGETS) to make sure that minisat is built. --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8da8b4c5..1bafd217 100644 --- a/Makefile +++ b/Makefile @@ -26,13 +26,17 @@ CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSY LDFLAGS = -I${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl +export PATH := ${DESTDIR}/bin:$(PATH) + ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': + export DYLD_LIBRARY_PATH := ${DESTDIR}/lib:$(DYLD_LIBRARY_PATH) CXXFLAGS += -I/opt/local/include LDFLAGS += -L/opt/local/lib QMAKE = qmake SED = gsed else + export LD_LIBRARY_PATH := ${DESTDIR}/lib:$(LD_LIBRARY_PATH) LDFLAGS += -rdynamic LDLIBS += -lrt QMAKE = qmake-qt4 @@ -132,7 +136,7 @@ yosys-config: yosys-config.in yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp cd libs/svgviewer && $(QMAKE) && make - cp libs/svgviewer/svgviewer yosys-svgviewer + cp `find libs/svgviewer -name svgviewer -type f` yosys-svgviewer yosys-minisat: $(DESTDIR)/bin/minisat $(DESTDIR)/bin/minisat: -- cgit v1.2.3 From 51bf1c871e89167228c406649201e608fd618d5c Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:12:20 +0100 Subject: - Makefile: fix typo in LDFLAGS: obviously -L, not -I is required here --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1bafd217..39b324b4 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ TARGETS = yosys yosys-config all: top-all CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSYS_ -fPIC -include kernel/posix_compatibility.h -LDFLAGS = -I${DESTDIR}/lib +LDFLAGS = -L${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl export PATH := ${DESTDIR}/bin:$(PATH) -- cgit v1.2.3 From cfabaa16895d85ce21b0a1bf020f5ac1108cc614 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Mon, 10 Mar 2014 20:27:39 +0100 Subject: - Makefile: include $(PWD) in PATH, since 'make test' can happen before 'make install'. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 39b324b4..9460e341 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSY LDFLAGS = -L${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl -export PATH := ${DESTDIR}/bin:$(PATH) +export PATH := $(PWD):$(DESTDIR)/bin:$(PATH) ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': -- cgit v1.2.3 From 948d04c06c181a1c270017b6d7c819426a360303 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Wed, 12 Mar 2014 14:12:52 +0100 Subject: - libs/minisat/System.cc: fix definition/declaration mismatch for Minisat::memUsedPeak() and mark unused parameters as unused to fix compiler error+warning. (minisat bug tracker issues #1, #9, #10.) --- libs/minisat/System.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/minisat/System.cc b/libs/minisat/System.cc index 01d0dfe1..59e65fb5 100644 --- a/libs/minisat/System.cc +++ b/libs/minisat/System.cc @@ -79,7 +79,7 @@ double Minisat::memUsed() { struct rusage ru; getrusage(RUSAGE_SELF, &ru); return (double)ru.ru_maxrss / 1024; } -double Minisat::memUsedPeak() { return memUsed(); } +double Minisat::memUsedPeak(bool strictlyPeak) { (void) strictlyPeak; return memUsed(); } #elif defined(__APPLE__) @@ -89,11 +89,11 @@ double Minisat::memUsed() { malloc_statistics_t t; malloc_zone_statistics(NULL, &t); return (double)t.max_size_in_use / (1024*1024); } -double Minisat::memUsedPeak() { return memUsed(); } +double Minisat::memUsedPeak(bool strictlyPeak) { (void) strictlyPeak; return memUsed(); } #else double Minisat::memUsed() { return 0; } -double Minisat::memUsedPeak() { return 0; } +double Minisat::memUsedPeak(bool strictlyPeak) { (void) strictlyPeak; return 0; } #endif -- cgit v1.2.3 From 18367919ea64a0881da7cf439c99365a8807d3a3 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Wed, 12 Mar 2014 14:15:53 +0100 Subject: - libs/minisat/Solver.cc: insert spaces between string and PRIu64 literal, otherwise c++11-compliant compilers will bail out due to user-defined literals (minisat bug tracker #13). --- libs/minisat/Solver.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/minisat/Solver.cc b/libs/minisat/Solver.cc index ebca294a..14aa3935 100644 --- a/libs/minisat/Solver.cc +++ b/libs/minisat/Solver.cc @@ -994,11 +994,11 @@ void Solver::printStats() const { double cpu_time = cpuTime(); double mem_used = memUsedPeak(); - printf("restarts : %"PRIu64"\n", starts); - printf("conflicts : %-12"PRIu64" (%.0f /sec)\n", conflicts , conflicts /cpu_time); - printf("decisions : %-12"PRIu64" (%4.2f %% random) (%.0f /sec)\n", decisions, (float)rnd_decisions*100 / (float)decisions, decisions /cpu_time); - printf("propagations : %-12"PRIu64" (%.0f /sec)\n", propagations, propagations/cpu_time); - printf("conflict literals : %-12"PRIu64" (%4.2f %% deleted)\n", tot_literals, (max_literals - tot_literals)*100 / (double)max_literals); + printf("restarts : %" PRIu64 "\n", starts); + printf("conflicts : %-12" PRIu64 " (%.0f /sec)\n", conflicts , conflicts /cpu_time); + printf("decisions : %-12" PRIu64 " (%4.2f %% random) (%.0f /sec)\n", decisions, (float)rnd_decisions*100 / (float)decisions, decisions /cpu_time); + printf("propagations : %-12" PRIu64 " (%.0f /sec)\n", propagations, propagations/cpu_time); + printf("conflict literals : %-12" PRIu64 " (%4.2f %% deleted)\n", tot_literals, (max_literals - tot_literals)*100 / (double)max_literals); if (mem_used != 0) printf("Memory used : %.2f MB\n", mem_used); printf("CPU time : %g s\n", cpu_time); } -- cgit v1.2.3 From a8efb61e1f5221bdb013d90e83530392f61c13f8 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Wed, 12 Mar 2014 14:16:55 +0100 Subject: - Makefile: follow changes in https://github.com/cliffordwolf/yosys --- Makefile | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 6950fcba..7bbc258d 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,6 @@ OBJS = kernel/version_$(GIT_REV).o ABCREV = 2058c8ccea68 ABCPULL = 1 -MINISATREV = HEAD - -include Makefile.conf ifeq ($(CONFIG),clang-debug) @@ -87,8 +85,8 @@ CXXFLAGS += -pg -fno-inline LDFLAGS += -pg endif -ifeq ($(ENABLE_MINISAT),1) -TARGETS += yosys-minisat +ifeq ($(ENABLE_QT4),1) +TARGETS += yosys-svgviewer endif ifeq ($(ENABLE_ABC),1) @@ -102,13 +100,9 @@ CXXFLAGS += $(patsubst %,-I$(VERIFIC_DIR)/%,$(VERIFIC_COMPONENTS)) -D'VERIFIC_DI LDLIBS += $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VERIFIC_COMPONENTS)) endif -# Build yosys after minisat and abc (we need to access the local copies of the downloaded/installed header files). +# Build yosys after abc (we need to access the the downloaded/installed header files and libraries when building yosys). TARGETS += yosys yosys-config -ifeq ($(ENABLE_QT4),1) -TARGETS += yosys-svgviewer -endif - OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o kernel/posix_compatibility.o OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o @@ -147,13 +141,6 @@ yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp cd libs/svgviewer && $(QMAKE) && make cp `find libs/svgviewer -name svgviewer -type f` yosys-svgviewer -yosys-minisat: $(DESTDIR)/bin/minisat -$(DESTDIR)/bin/minisat: - test -d minisat || ( git clone https://github.com/niklasso/minisat.git minisat && $(SED) -i -e 's/PRIi64/ & /' minisat/minisat/utils/Options.h ) - ( cd minisat && git checkout $(MINISATREV) ) - ( cd minisat && $(MAKE) prefix=$(DESTDIR) DESTDIR="" config install ) - @( cd minisat && echo "Installed minisat version `git describe --always --dirty` into $(DESTDIR)." ) - abc/abc-$(ABCREV): ifneq ($(ABCREV),default) if ( cd abc && hg identify; ) | grep -q +; then \ -- cgit v1.2.3 From aead1b75e81b98332583ec859aa02c9757cc359f Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Wed, 12 Mar 2014 14:18:07 +0100 Subject: - .gitignore: ignore qmake/OSX package libs/svgviewer/svgviewer.app --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 77d6e29e..10491a3a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /qtcreator.config /qtcreator.creator /qtcreator.creator.user +/libs/svgviewer/svgviewer.app /Makefile.conf /minisat /abc -- cgit v1.2.3 From 50423e3935095e535aa42aa17c80f0d178730e93 Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Wed, 12 Mar 2014 14:42:26 +0100 Subject: - Makefile: don't export DYLD_LIBRARY_PATH/LD_LIBRARY_PATH: not needed if we link minisat objects instead of library --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 7bbc258d..f7b466fd 100644 --- a/Makefile +++ b/Makefile @@ -30,13 +30,11 @@ export PATH := $(PWD):$(DESTDIR)/bin:$(PATH) ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': - export DYLD_LIBRARY_PATH := ${DESTDIR}/lib:$(DYLD_LIBRARY_PATH) CXXFLAGS += -I/opt/local/include LDFLAGS += -L/opt/local/lib QMAKE = qmake SED = gsed else - export LD_LIBRARY_PATH := ${DESTDIR}/lib:$(LD_LIBRARY_PATH) LDFLAGS += -rdynamic LDLIBS += -lrt QMAKE = qmake-qt4 -- cgit v1.2.3 From 5a50760e2c327ded7a4da223fb16591febcb773f Mon Sep 17 00:00:00 2001 From: Siesh1oo Date: Wed, 12 Mar 2014 18:33:37 +0100 Subject: - kernel/register.h, kernel/driver.cc: refactor rewrite_yosys_exe()/get_share_file_name() to portable proc_self_dirname()/proc_share_dirname(). This refactoring improves robustness and allows OSX support with only 7 new lines of code, and easy extension for other systems. - passes/abc/abc.cc, passes/cmds/show.cc, passes/techmap/techmap.cc: use new, refactored semantics. - Makefile: no need to add $(PWD) to $(PATH) anymore. --- Makefile | 2 -- kernel/driver.cc | 69 +++++++++++++++++++++++++---------------------- kernel/register.h | 4 +-- passes/abc/abc.cc | 2 +- passes/cmds/show.cc | 3 ++- passes/techmap/techmap.cc | 3 ++- 6 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index f7b466fd..b7bf4485 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,6 @@ CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSY LDFLAGS = -L${DESTDIR}/lib LDLIBS = -lstdc++ -lreadline -lm -ldl -export PATH := $(PWD):$(DESTDIR)/bin:$(PATH) - ifeq (Darwin,$(findstring Darwin,$(shell uname))) # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt': CXXFLAGS += -I/opt/local/include diff --git a/kernel/driver.cc b/kernel/driver.cc index ce95cad4..da4962b8 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -427,42 +428,46 @@ extern RTLIL::Design *yosys_get_design() return yosys_design; } -std::string rewrite_yosys_exe(std::string exe) +#if defined(__linux__) +std::string proc_self_dirname () { - char buffer[1024]; - ssize_t buflen = readlink("/proc/self/exe", buffer, sizeof(buffer)-1); - - if (buflen < 0) - return exe; - - buffer[buflen] = 0; - std::string newexe = stringf("%s/%s", dirname(buffer), exe.c_str()); - if (access(newexe.c_str(), X_OK) == 0) - return newexe; - - return exe; + char path [PATH_MAX]; + ssize_t buflen = readlink("/proc/self/exe", path, sizeof(path)); + if (buflen < 0) { + log_cmd_error("readlink(\"/proc/self/exe\") failed: %s", strerror(errno)); + log_abort(); + } + while (buflen > 0 && path[buflen-1] != '/') + buflen--; + return std::string(path, buflen); } - -std::string get_share_file_name(std::string file) +#elif defined(__APPLE__) +#include +std::string proc_self_dirname () { - char buffer[1024]; - ssize_t buflen = readlink("/proc/self/exe", buffer, sizeof(buffer)-1); - - if (buflen < 0) - log_error("Can't find file `%s': reading of /proc/self/exe failed!\n", file.c_str()); - - buffer[buflen] = 0; - const char *dir = dirname(buffer); - - std::string newfile_inplace = stringf("%s/share/%s", dir, file.c_str()); - if (access(newfile_inplace.c_str(), F_OK) == 0) - return newfile_inplace; - - std::string newfile_system = stringf("%s/../share/yosys/%s", dir, file.c_str()); - if (access(newfile_system.c_str(), F_OK) == 0) - return newfile_system; + char * path = NULL; + uint32_t buflen = 0; + while (_NSGetExecutablePath(path, &buflen) != 0) + path = (char *) realloc((void *) path, buflen); + while (buflen > 0 && path[buflen-1] != '/') + buflen--; + return std::string(path, buflen); +} +#else + #error Dont know how to determine process executable base path! +#endif - log_error("Can't find file `%s': no `%s' and no `%s' found!\n", file.c_str(), newfile_inplace.c_str(), newfile_system.c_str()); +std::string proc_share_dirname () +{ + std::string proc_self_path = proc_self_dirname(); + std::string proc_share_path = proc_self_path + "share/"; + if (access(proc_share_path.c_str(), X_OK) == 0) + return proc_share_path; + proc_share_path = proc_self_path + "../share/yosys/"; + if (access(proc_share_path.c_str(), X_OK) == 0) + return proc_share_path; + log_cmd_error("proc_share_dirname: unable to determine share/ directory!"); + log_abort(); } int main(int argc, char **argv) diff --git a/kernel/register.h b/kernel/register.h index b582f98c..f3d3f70a 100644 --- a/kernel/register.h +++ b/kernel/register.h @@ -36,8 +36,8 @@ extern const char *yosys_version_str; // implemented in driver.cc extern RTLIL::Design *yosys_get_design(); -std::string rewrite_yosys_exe(std::string exe); -std::string get_share_file_name(std::string file); +extern std::string proc_self_dirname(); +extern std::string proc_share_dirname(); const char *create_prompt(RTLIL::Design *design, int recursion_counter); // from passes/cmds/design.cc diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index 286b750c..30e78e58 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -969,7 +969,7 @@ struct AbcPass : public Pass { log_header("Executing ABC pass (technology mapping using ABC).\n"); log_push(); - std::string exe_file = rewrite_yosys_exe("yosys-abc"); + std::string exe_file = proc_self_dirname() + "yosys-abc"; std::string script_file, liberty_file, constr_file, clk_str; bool dff_mode = false, keepff = false, cleanup = true; int lut_mode = 0; diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index fdccb4bc..bf37e5da 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -751,7 +751,8 @@ struct ShowPass : public Pass { log_cmd_error("Shell command failed!\n"); } else if (format.empty()) { - std::string cmd = stringf("fuser -s '%s' || '%s' '%s' &", out_file.c_str(), rewrite_yosys_exe("yosys-svgviewer").c_str(), out_file.c_str()); + std::string svgviewer = proc_self_dirname() + "yosys-svgviewer"; + std::string cmd = stringf("fuser -s '%s' || '%s' '%s' &", out_file.c_str(), svgviewer.c_str(), out_file.c_str()); log("Exec: %s\n", cmd.c_str()); if (system(cmd.c_str()) != 0) log_cmd_error("Shell command failed!\n"); diff --git a/passes/techmap/techmap.cc b/passes/techmap/techmap.cc index 937f4131..0ca601e3 100644 --- a/passes/techmap/techmap.cc +++ b/passes/techmap/techmap.cc @@ -548,13 +548,14 @@ struct TechmapPass : public Pass { int max_iter = -1; size_t argidx; + std::string proc_share_path = proc_share_dirname(); for (argidx = 1; argidx < args.size(); argidx++) { if (args[argidx] == "-map" && argidx+1 < args.size()) { map_files.push_back(args[++argidx]); continue; } if (args[argidx] == "-share_map" && argidx+1 < args.size()) { - map_files.push_back(get_share_file_name(args[++argidx])); + map_files.push_back(proc_share_path + args[++argidx]); continue; } if (args[argidx] == "-max_iter" && argidx+1 < args.size()) { -- cgit v1.2.3