From 793b9ade56bbc06d9d03dc0522de4ea0cd656b4f Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Fri, 8 Jul 2022 12:40:26 +0200 Subject: [PATCH 1/3] extends the list of platforms without This permits to fix a compilation bug on OpenBSD https://www.gnu.org/software/gnulib/manual/html_node/alloca_002eh.html > This header file is missing on some platforms: > FreeBSD 6.0, NetBSD 9.0, OpenBSD 6.7, mingw, MSVC 14. --- libs/fst/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/fst/config.h b/libs/fst/config.h index cd036f16a..a2f0fca82 100644 --- a/libs/fst/config.h +++ b/libs/fst/config.h @@ -21,7 +21,7 @@ #undef HAVE_LIBPTHREAD #undef HAVE_FSEEKO #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) #undef HAVE_ALLOCA_H #endif From 6eba56fcf0c8f5e7bddfdf2d71fd157c71876ae8 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Fri, 8 Jul 2022 13:39:18 +0200 Subject: [PATCH 2/3] include changes to support OpenBSD and prepare NetBSD support Some systems do not split -lrt and -ldl from the main libc. Musl libc is one of them, but offers an empty -ldl and -lrt precisely to avoid these kind of compilation errors. OpenBSD tried to add a librt.a but it broke libtool-based packages on multiple OSes[1] so it got reverted, nad -lrt needs to be removed. Some other adjustments for FreeBSD also work for other BSD, like packages in /usr/local/ instead of /usr/, TLC libraries... [1]: https://marc.info/?l=openbsd-tech&m=139559970907629&w=2 --- Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 92416d1b0..65efc62a5 100644 --- a/Makefile +++ b/Makefile @@ -126,8 +126,10 @@ endif else LDFLAGS += -rdynamic +ifneq ($(OS), OpenBSD) LDLIBS += -lrt endif +endif YOSYS_VER := 0.19+18 @@ -395,7 +397,7 @@ endif # ENABLE_PYOSYS ifeq ($(ENABLE_READLINE),1) CXXFLAGS += -DYOSYS_ENABLE_READLINE -ifeq ($(OS), FreeBSD) +ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD)) CXXFLAGS += -I/usr/local/include endif LDLIBS += -lreadline @@ -430,7 +432,7 @@ endif ifeq ($(ENABLE_PLUGINS),1) CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) -DYOSYS_ENABLE_PLUGINS LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi) -ifneq ($(OS), FreeBSD) +ifneq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD)) LDLIBS += -ldl endif endif @@ -447,7 +449,7 @@ endif ifeq ($(ENABLE_TCL),1) TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')") -ifeq ($(OS), FreeBSD) +ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD)) TCL_INCLUDE ?= /usr/local/include/$(TCL_VERSION) else TCL_INCLUDE ?= /usr/include/$(TCL_VERSION) @@ -458,8 +460,8 @@ CXXFLAGS += -DYOSYS_ENABLE_TCL LDLIBS += -ltcl86 -lwsock32 -lws2_32 -lnetapi32 -lz -luserenv else CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL -ifeq ($(OS), FreeBSD) -# FreeBSD uses tcl8.6, but lib is named "libtcl86" +ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD)) +# BSDs usually use tcl8.6, but the lib is named "libtcl86" LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION) | tr -d '.') else LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION)) From 58fddf61ccd4715150f1dba40e62eac650ef9ee3 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Sat, 16 Jul 2022 00:47:00 +0200 Subject: [PATCH 3/3] reduce the Makefile TCL compatibility code --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 65efc62a5..99f7f8996 100644 --- a/Makefile +++ b/Makefile @@ -450,9 +450,12 @@ endif ifeq ($(ENABLE_TCL),1) TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')") ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD)) +# BSDs usually use tcl8.6, but the lib is named "libtcl86" TCL_INCLUDE ?= /usr/local/include/$(TCL_VERSION) +TCL_LIBS ?= -l$(subst .,,$(TCL_VERSION)) else TCL_INCLUDE ?= /usr/include/$(TCL_VERSION) +TCL_LIBS ?= -l$(TCL_VERSION) endif ifeq ($(CONFIG),mxe) @@ -460,12 +463,7 @@ CXXFLAGS += -DYOSYS_ENABLE_TCL LDLIBS += -ltcl86 -lwsock32 -lws2_32 -lnetapi32 -lz -luserenv else CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL -ifeq ($(OS), $(filter $(OS),FreeBSD OpenBSD NetBSD)) -# BSDs usually use tcl8.6, but the lib is named "libtcl86" -LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION) | tr -d '.') -else -LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION)) -endif +LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo $(TCL_LIBS)) endif endif