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 3a886b1c8..59f936b01 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 5a4e091cf..b02287962 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 fd5fa86e1..4bf73358b 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 2829e660f..24a634f65 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 fb3d24996..6da363fc1 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 c4c03352a..fbc3c1c39 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 00a61ec0f..ce95cad4f 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 ee14ffbad..ab5cba11b 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 0467810e5..d8568fe94 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 385ee2c0a..45febc2f9 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 f251d2b6d..77d6e29e5 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 a68ceccb4..c0d43a2c3 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 000000000..d3fb00873 --- /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 000000000..d6eaade05 --- /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 d488a9062..92f56b00a 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 c0d43a2c3..7bd8a450e 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 6d94d5c9b..c68b13f6c 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 d8568fe94..83035d329 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 24a634f65..286b750cc 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 7bd8a450e..82c09d058 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 82c09d058..849860a33 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 92f56b00a..4677f68bd 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 849860a33..ce9a99bc0 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 ae1ebbb56..b83ab8495 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 abb473ba9..5f40b594f 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 5f40b594f..ad68ee1e3 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 ad68ee1e3..75a8f42bb 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 75a8f42bb..9f888c861 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 ce9a99bc0..c1c81b8e7 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