mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #4502 from YosysHQ/emil/build-opt-levels
Release build configuration improvements
This commit is contained in:
commit
e21dd292fc
|
@ -14,7 +14,7 @@ runs:
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install bison flex gawk libffi pkg-config bash autoconf
|
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install bison flex gawk libffi pkg-config bash autoconf llvm
|
||||||
|
|
||||||
- name: Linux runtime environment
|
- name: Linux runtime environment
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
|
@ -28,6 +28,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "${{ github.workspace }}/.local/bin" >> $GITHUB_PATH
|
echo "${{ github.workspace }}/.local/bin" >> $GITHUB_PATH
|
||||||
|
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
|
||||||
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH
|
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH
|
||||||
echo "$(brew --prefix flex)/bin" >> $GITHUB_PATH
|
echo "$(brew --prefix flex)/bin" >> $GITHUB_PATH
|
||||||
echo "procs=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
|
echo "procs=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
|
||||||
|
|
3
Brewfile
3
Brewfile
|
@ -9,4 +9,5 @@ brew "python3"
|
||||||
brew "tcl-tk"
|
brew "tcl-tk"
|
||||||
brew "xdot"
|
brew "xdot"
|
||||||
brew "bash"
|
brew "bash"
|
||||||
brew 'boost-python3'
|
brew "boost-python3"
|
||||||
|
brew "llvm"
|
||||||
|
|
|
@ -8,6 +8,7 @@ RUN apt-get update -qq \
|
||||||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
clang \
|
clang \
|
||||||
|
lld \
|
||||||
curl \
|
curl \
|
||||||
libffi-dev \
|
libffi-dev \
|
||||||
libreadline-dev \
|
libreadline-dev \
|
||||||
|
|
50
Makefile
50
Makefile
|
@ -34,7 +34,7 @@ ENABLE_PYOSYS := 0
|
||||||
ENABLE_GCOV := 0
|
ENABLE_GCOV := 0
|
||||||
ENABLE_GPROF := 0
|
ENABLE_GPROF := 0
|
||||||
ENABLE_DEBUG := 0
|
ENABLE_DEBUG := 0
|
||||||
ENABLE_NDEBUG := 0
|
ENABLE_LTO := 1
|
||||||
ENABLE_CCACHE := 0
|
ENABLE_CCACHE := 0
|
||||||
# sccache is not always a drop-in replacement for ccache in practice
|
# sccache is not always a drop-in replacement for ccache in practice
|
||||||
ENABLE_SCCACHE := 0
|
ENABLE_SCCACHE := 0
|
||||||
|
@ -53,6 +53,11 @@ SANITIZER =
|
||||||
# SANITIZER = undefined
|
# SANITIZER = undefined
|
||||||
# SANITIZER = cfi
|
# SANITIZER = cfi
|
||||||
|
|
||||||
|
# Prefer using ENABLE_DEBUG over setting these
|
||||||
|
OPT_LEVEL := -O3
|
||||||
|
GCC_LTO :=
|
||||||
|
CLANG_LTO := -flto=thin
|
||||||
|
|
||||||
PROGRAM_PREFIX :=
|
PROGRAM_PREFIX :=
|
||||||
|
|
||||||
OS := $(shell uname -s)
|
OS := $(shell uname -s)
|
||||||
|
@ -212,10 +217,15 @@ ifeq ($(OS), OpenBSD)
|
||||||
ABC_ARCHFLAGS += "-DABC_NO_RLIMIT"
|
ABC_ARCHFLAGS += "-DABC_NO_RLIMIT"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# This gets overridden later.
|
||||||
|
LTOFLAGS := $(GCC_LTO)
|
||||||
|
|
||||||
ifeq ($(CONFIG),clang)
|
ifeq ($(CONFIG),clang)
|
||||||
CXX = clang++
|
CXX = clang++
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL)
|
||||||
|
LINKFLAGS += -fuse-ld=lld
|
||||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H $(ABC_ARCHFLAGS)"
|
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H $(ABC_ARCHFLAGS)"
|
||||||
|
LTOFLAGS := $(CLANG_LTO)
|
||||||
|
|
||||||
ifneq ($(SANITIZER),)
|
ifneq ($(SANITIZER),)
|
||||||
$(info [Clang Sanitizer] $(SANITIZER))
|
$(info [Clang Sanitizer] $(SANITIZER))
|
||||||
|
@ -231,19 +241,20 @@ endif
|
||||||
ifneq ($(findstring cfi,$(SANITIZER)),)
|
ifneq ($(findstring cfi,$(SANITIZER)),)
|
||||||
CXXFLAGS += -flto
|
CXXFLAGS += -flto
|
||||||
LINKFLAGS += -flto
|
LINKFLAGS += -flto
|
||||||
|
LTOFLAGS =
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
else ifeq ($(CONFIG),gcc)
|
else ifeq ($(CONFIG),gcc)
|
||||||
CXX = g++
|
CXX = g++
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL)
|
||||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H $(ABC_ARCHFLAGS)"
|
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H $(ABC_ARCHFLAGS)"
|
||||||
|
|
||||||
else ifeq ($(CONFIG),gcc-static)
|
else ifeq ($(CONFIG),gcc-static)
|
||||||
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -static
|
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -static
|
||||||
LIBS := $(filter-out -lrt,$(LIBS))
|
LIBS := $(filter-out -lrt,$(LIBS))
|
||||||
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL)
|
||||||
ABCMKARGS = CC="$(CC)" CXX="$(CXX)" LD="$(CXX)" ABC_USE_LIBSTDCXX=1 LIBS="-lm -lpthread -static" OPTFLAGS="-O" \
|
ABCMKARGS = CC="$(CC)" CXX="$(CXX)" LD="$(CXX)" ABC_USE_LIBSTDCXX=1 LIBS="-lm -lpthread -static" OPTFLAGS="-O" \
|
||||||
ARCHFLAGS="-DABC_USE_STDINT_H -DABC_NO_DYNAMIC_LINKING=1 -Wno-unused-but-set-variable $(ARCHFLAGS)" ABC_USE_NO_READLINE=1
|
ARCHFLAGS="-DABC_USE_STDINT_H -DABC_NO_DYNAMIC_LINKING=1 -Wno-unused-but-set-variable $(ARCHFLAGS)" ABC_USE_NO_READLINE=1
|
||||||
ifeq ($(DISABLE_ABC_THREADS),1)
|
ifeq ($(DISABLE_ABC_THREADS),1)
|
||||||
|
@ -252,12 +263,12 @@ endif
|
||||||
|
|
||||||
else ifeq ($(CONFIG),afl-gcc)
|
else ifeq ($(CONFIG),afl-gcc)
|
||||||
CXX = AFL_QUIET=1 AFL_HARDEN=1 afl-gcc
|
CXX = AFL_QUIET=1 AFL_HARDEN=1 afl-gcc
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL)
|
||||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
|
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
|
||||||
|
|
||||||
else ifeq ($(CONFIG),cygwin)
|
else ifeq ($(CONFIG),cygwin)
|
||||||
CXX = g++
|
CXX = g++
|
||||||
CXXFLAGS += -std=gnu++11 -Os
|
CXXFLAGS += -std=gnu++11 $(OPT_LEVEL)
|
||||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
|
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
|
||||||
|
|
||||||
else ifeq ($(CONFIG),wasi)
|
else ifeq ($(CONFIG),wasi)
|
||||||
|
@ -272,7 +283,7 @@ AR = $(WASI_SDK)/bin/ar
|
||||||
RANLIB = $(WASI_SDK)/bin/ranlib
|
RANLIB = $(WASI_SDK)/bin/ranlib
|
||||||
WASIFLAGS := --sysroot $(WASI_SDK)/share/wasi-sysroot $(WASIFLAGS)
|
WASIFLAGS := --sysroot $(WASI_SDK)/share/wasi-sysroot $(WASIFLAGS)
|
||||||
endif
|
endif
|
||||||
CXXFLAGS := $(WASIFLAGS) -std=$(CXXSTD) -Os -D_WASI_EMULATED_PROCESS_CLOCKS $(filter-out -fPIC,$(CXXFLAGS))
|
CXXFLAGS := $(WASIFLAGS) -std=$(CXXSTD) $(OPT_LEVEL) -D_WASI_EMULATED_PROCESS_CLOCKS $(filter-out -fPIC,$(CXXFLAGS))
|
||||||
LINKFLAGS := $(WASIFLAGS) -Wl,-z,stack-size=1048576 $(filter-out -rdynamic,$(LINKFLAGS))
|
LINKFLAGS := $(WASIFLAGS) -Wl,-z,stack-size=1048576 $(filter-out -rdynamic,$(LINKFLAGS))
|
||||||
LIBS := -lwasi-emulated-process-clocks $(filter-out -lrt,$(LIBS))
|
LIBS := -lwasi-emulated-process-clocks $(filter-out -lrt,$(LIBS))
|
||||||
ABCMKARGS += AR="$(AR)" RANLIB="$(RANLIB)"
|
ABCMKARGS += AR="$(AR)" RANLIB="$(RANLIB)"
|
||||||
|
@ -290,7 +301,7 @@ endif
|
||||||
else ifeq ($(CONFIG),mxe)
|
else ifeq ($(CONFIG),mxe)
|
||||||
PKG_CONFIG = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-pkg-config
|
PKG_CONFIG = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-pkg-config
|
||||||
CXX = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-g++
|
CXX = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-g++
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os -D_POSIX_SOURCE -DYOSYS_MXE_HACKS -Wno-attributes
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL) -D_POSIX_SOURCE -DYOSYS_MXE_HACKS -Wno-attributes
|
||||||
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
||||||
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -s
|
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -s
|
||||||
LIBS := $(filter-out -lrt,$(LIBS))
|
LIBS := $(filter-out -lrt,$(LIBS))
|
||||||
|
@ -301,7 +312,7 @@ EXE = .exe
|
||||||
|
|
||||||
else ifeq ($(CONFIG),msys2-32)
|
else ifeq ($(CONFIG),msys2-32)
|
||||||
CXX = i686-w64-mingw32-g++
|
CXX = i686-w64-mingw32-g++
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL) -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
|
||||||
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
||||||
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -s
|
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -s
|
||||||
LIBS := $(filter-out -lrt,$(LIBS))
|
LIBS := $(filter-out -lrt,$(LIBS))
|
||||||
|
@ -311,7 +322,7 @@ EXE = .exe
|
||||||
|
|
||||||
else ifeq ($(CONFIG),msys2-64)
|
else ifeq ($(CONFIG),msys2-64)
|
||||||
CXX = x86_64-w64-mingw32-g++
|
CXX = x86_64-w64-mingw32-g++
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL) -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
|
||||||
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
|
||||||
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -s
|
LINKFLAGS := $(filter-out -rdynamic,$(LINKFLAGS)) -s
|
||||||
LIBS := $(filter-out -lrt,$(LIBS))
|
LIBS := $(filter-out -lrt,$(LIBS))
|
||||||
|
@ -320,13 +331,20 @@ ABCMKARGS += LIBS="-lpthread -lshlwapi -s" ABC_USE_NO_READLINE=0 CC="x86_64-w64-
|
||||||
EXE = .exe
|
EXE = .exe
|
||||||
|
|
||||||
else ifeq ($(CONFIG),none)
|
else ifeq ($(CONFIG),none)
|
||||||
CXXFLAGS += -std=$(CXXSTD) -Os
|
CXXFLAGS += -std=$(CXXSTD) $(OPT_LEVEL)
|
||||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H $(ABC_ARCHFLAGS)"
|
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H $(ABC_ARCHFLAGS)"
|
||||||
|
LTOFLAGS =
|
||||||
|
|
||||||
else
|
else
|
||||||
$(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, mxe, msys2-32, msys2-64, none)
|
$(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, mxe, msys2-32, msys2-64, none)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_LTO),1)
|
||||||
|
CXXFLAGS += $(LTOFLAGS)
|
||||||
|
LINKFLAGS += $(LTOFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_LIBYOSYS),1)
|
ifeq ($(ENABLE_LIBYOSYS),1)
|
||||||
TARGETS += libyosys.so
|
TARGETS += libyosys.so
|
||||||
endif
|
endif
|
||||||
|
@ -441,16 +459,8 @@ CXXFLAGS += -pg
|
||||||
LINKFLAGS += -pg
|
LINKFLAGS += -pg
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_NDEBUG),1)
|
|
||||||
CXXFLAGS := -O3 -DNDEBUG $(filter-out -Os -ggdb,$(CXXFLAGS))
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(ENABLE_DEBUG),1)
|
ifeq ($(ENABLE_DEBUG),1)
|
||||||
ifeq ($(CONFIG),clang)
|
CXXFLAGS := -Og -DDEBUG $(filter-out $(OPT_LEVEL),$(CXXFLAGS))
|
||||||
CXXFLAGS := -O0 -DDEBUG $(filter-out -Os,$(CXXFLAGS))
|
|
||||||
else
|
|
||||||
CXXFLAGS := -Og -DDEBUG $(filter-out -Os,$(CXXFLAGS))
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_ABC),1)
|
ifeq ($(ENABLE_ABC),1)
|
||||||
|
|
|
@ -79,7 +79,7 @@ Xdot (graphviz) is used by the ``show`` command in yosys to display schematics.
|
||||||
For example on Ubuntu Linux 16.04 LTS the following commands will install all
|
For example on Ubuntu Linux 16.04 LTS the following commands will install all
|
||||||
prerequisites for building yosys:
|
prerequisites for building yosys:
|
||||||
|
|
||||||
$ sudo apt-get install build-essential clang bison flex \
|
$ sudo apt-get install build-essential clang lld bison flex \
|
||||||
libreadline-dev gawk tcl-dev libffi-dev git \
|
libreadline-dev gawk tcl-dev libffi-dev git \
|
||||||
graphviz xdot pkg-config python3 libboost-system-dev \
|
graphviz xdot pkg-config python3 libboost-system-dev \
|
||||||
libboost-python-dev libboost-filesystem-dev zlib1g-dev
|
libboost-python-dev libboost-filesystem-dev zlib1g-dev
|
||||||
|
|
|
@ -94,7 +94,7 @@ Installing all prerequisites for Ubuntu 20.04:
|
||||||
|
|
||||||
.. code:: console
|
.. code:: console
|
||||||
|
|
||||||
sudo sudo apt-get install build-essential clang bison flex \
|
sudo sudo apt-get install build-essential clang lld bison flex \
|
||||||
libreadline-dev gawk tcl-dev libffi-dev git make \
|
libreadline-dev gawk tcl-dev libffi-dev git make \
|
||||||
graphviz xdot pkg-config python3 libboost-system-dev \
|
graphviz xdot pkg-config python3 libboost-system-dev \
|
||||||
libboost-python-dev libboost-filesystem-dev zlib1g-dev
|
libboost-python-dev libboost-filesystem-dev zlib1g-dev
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
yosys = pkgs.clangStdenv.mkDerivation {
|
yosys = pkgs.clangStdenv.mkDerivation {
|
||||||
name = "yosys";
|
name = "yosys";
|
||||||
src = ./. ;
|
src = ./. ;
|
||||||
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git pkg-configUpstream ];
|
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git pkg-configUpstream llvmPackages.bintools ];
|
||||||
checkInputs = with pkgs; [ gtest ];
|
checkInputs = with pkgs; [ gtest ];
|
||||||
propagatedBuildInputs = [ abc-verifier ];
|
propagatedBuildInputs = [ abc-verifier ];
|
||||||
preConfigure = "make config-clang";
|
preConfigure = "make config-clang";
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
packages.default = yosys;
|
packages.default = yosys;
|
||||||
defaultPackage = yosys;
|
defaultPackage = yosys;
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git gtest abc-verifier ];
|
buildInputs = with pkgs; [ clang llvmPackages.bintools bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git gtest abc-verifier ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue