From 06a8b5f8f6a46f32fd08e53b48b374cd5fed4522 Mon Sep 17 00:00:00 2001 From: Ed Bordin Date: Thu, 20 May 2021 11:29:19 +1000 Subject: [PATCH 1/3] #79 hopefully fix ghdl build by patching GNAT_LARGS back in, reorganise patches, add option to skip symbol stripping for dev --- azure-pipelines.yml | 2 + build.sh | 2 + patches/ghdl/ghdl_largs.patch | 62 +++++++++++++++++++ .../ghdl/ghdl_version.patch | 0 .../ghdl/libghdl_static.patch | 0 .../yosys/yosys_ghdl.patch | 0 scripts/_common.sh | 8 ++- scripts/compile_ghdl.sh | 3 +- scripts/compile_yosys.sh | 7 ++- 9 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 patches/ghdl/ghdl_largs.patch rename scripts/ghdl_version.diff => patches/ghdl/ghdl_version.patch (100%) rename scripts/libghdl_static.diff => patches/ghdl/libghdl_static.patch (100%) rename scripts/yosys_ghdl.diff => patches/yosys/yosys_ghdl.patch (100%) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 99042e5..41decbd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,6 +17,8 @@ variables: value: "1" - name: CLEAN_AFTER_BUILD value: "1" +- name: STRIP_SYMBOLS + value: "1" - name: COMPILE_DFU_UTIL value: "1" - name: COMPILE_YOSYS diff --git a/build.sh b/build.sh index 9680506..96db405 100755 --- a/build.sh +++ b/build.sh @@ -24,6 +24,8 @@ INSTALL_DEPS="${INSTALL_DEPS:-1}" # (keeps disk space usage lower in CI runs) CLEAN_AFTER_BUILD="${CLEAN_AFTER_BUILD:-1}" +STRIP_SYMBOLS="${STRIP_SYMBOLS:-1}" + # Enable each individual tool COMPILE_DFU_UTIL="${COMPILE_DFU_UTIL:-1}" COMPILE_YOSYS="${COMPILE_YOSYS:-1}" diff --git a/patches/ghdl/ghdl_largs.patch b/patches/ghdl/ghdl_largs.patch new file mode 100644 index 0000000..5eade61 --- /dev/null +++ b/patches/ghdl/ghdl_largs.patch @@ -0,0 +1,62 @@ +diff --git a/Makefile.in b/Makefile.in +index ddae0c82..2ab769d0 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -200,7 +200,7 @@ GHDL_MCODE_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir + ghdl_mcode$(EXEEXT): GRT_FLAGS+=-DWITH_GNAT_RUN_TIME + ghdl_mcode$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) $(ORTHO_DEPS) \ + memsegs_c.o chkstk.o version.ads force +- $(GNATMAKE) -o $@ -gnat12 $(GHDL_MCODE_INCFLAGS) $(GNATFLAGS) -gnatw.A ghdl_jit.adb $(GNAT_BARGS) -largs memsegs_c.o chkstk.o $(GRT_ADD_OBJS) $(LDFLAGS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB) $(GRT_EXEC_OPTS)) ++ $(GNATMAKE) -o $@ -gnat12 $(GHDL_MCODE_INCFLAGS) $(GNATFLAGS) -gnatw.A ghdl_jit.adb $(GNAT_BARGS) -largs memsegs_c.o chkstk.o $(GRT_ADD_OBJS) $(LDFLAGS) $(GNAT_LARGS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB) $(GRT_EXEC_OPTS)) + + memsegs_c.o: $(srcdir)/src/ortho/mcode/memsegs_c.c + $(CC) -c $(COVERAGE_FLAGS) $(CFLAGS) -o $@ $< +@@ -314,7 +314,7 @@ ghdl1-gcc$(EXEEXT): version.ads force + ghdl_gcc$(EXEEXT): version.ads $(GRT_SYNTH_OBJS) force + $(GNATMAKE) $(GHDL_GCC_INCFLAGS) -aI$(srcdir)/src/ghdldrv \ + $(GNATFLAGS) ghdl_gcc $(GNAT_BARGS) \ +- -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) ++ -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) $(GNAT_LARGS) + + libs.vhdl.local_gcc: ghdl_gcc$(EXEEXT) ghdl1-gcc$(EXEEXT) + $(MAKE) -f $(srcdir)/libraries/Makefile.inc $(LIBVHDL_FLAGS_TO_PASS) GHDL=$(PWD)/ghdl_gcc$(EXEEXT) GHDL_FLAGS="--GHDL1=$(PWD)/ghdl1-gcc$(EXEEXT) $(LIB_CFLAGS)" vhdl.libs.all libs.vhdl.standard +@@ -342,7 +342,7 @@ ghdl_llvm_jit$(EXEEXT): GRT_FLAGS+=-DWITH_GNAT_RUN_TIME + ghdl_llvm_jit$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) $(ORTHO_DEPS) \ + llvm-cbindings.o version.ads force + $(GNATMAKE) -o $@ $(GHDL_LLVM_INCFLAGS) $(GNATFLAGS) ghdl_jit.adb \ +- $(GNAT_BARGS) -largs llvm-cbindings.o $(GRT_ADD_OBJS) \ ++ $(GNAT_BARGS) -largs llvm-cbindings.o $(GNAT_LARGS) $(GRT_ADD_OBJS) \ + $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) --LINK=$(CXX) \ + `$(LLVM_CONFIG) --ldflags --libs --system-libs` $(LDFLAGS) + +@@ -363,7 +363,7 @@ ghdl_llvm$(EXEEXT): version.ads $(GRT_SYNTH_OBJS) force + $(GNATMAKE) $(GHDL_LLVM_INCFLAGS) \ + -aI$(srcdir)/src/ghdldrv $(GNATFLAGS) \ + ghdl_llvm $(GNAT_BARGS) \ +- -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) ++ -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) $(GNAT_LARGS) + + ghdl1-llvm$(EXEEXT): version.ads force + $(MAKE) -f $(srcdir)/src/ortho/$(llvm_be)/Makefile \ +@@ -400,7 +400,7 @@ uninstall.llvm: uninstall.llvm.program uninstall.grt + GHDL_SIMUL_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/vhdl/simulate -aI$(srcdir)/src/synth + + ghdl_simul$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) version.ads force +- $(GNATMAKE) $(GHDL_SIMUL_INCFLAGS) $(GNATFLAGS) -gnat12 ghdl_simul $(GNAT_BARGS) -largs $(LDFLAGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) ++ $(GNATMAKE) $(GHDL_SIMUL_INCFLAGS) $(GNATFLAGS) -gnat12 ghdl_simul $(GNAT_BARGS) -largs $(LDFLAGS) $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) + + libs.vhdl.simul: ghdl_simul$(EXEEXT) + $(MAKE) -f $(srcdir)/libraries/Makefile.inc $(LIBVHDL_FLAGS_TO_PASS) GHDL=$(PWD)/ghdl_simul$(EXEEXT) GHDL_FLAGS="" VHDLLIBS_COPY_OBJS=no vhdl.libs.all +diff --git a/scripts/windows/mcode/Makefile.in b/scripts/windows/mcode/Makefile.in +index 0f7b7422..be1f1151 100644 +--- a/scripts/windows/mcode/Makefile.in ++++ b/scripts/windows/mcode/Makefile.in +@@ -14,7 +14,7 @@ GRTSRCDIR=grt + ####grt Makefile.inc + + ghdl_mcode: default_paths.ads $(GRT_ADD_OBJS) mmap_binding.o force +- gnatmake -aIghdldrv -aIghdl -aIortho -aIgrt $(GNATFLAGS) ghdl_mcode $(GNAT_BARGS) -largs mmap_binding.o $(GRT_ADD_OBJS) $(GRT_EXTRA_LIB) -Wl,--version-script=$(GRTSRCDIR)/grt.ver -Wl,--export-dynamic ++ gnatmake -aIghdldrv -aIghdl -aIortho -aIgrt $(GNATFLAGS) ghdl_mcode $(GNAT_BARGS) -largs mmap_binding.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(GRT_EXTRA_LIB) -Wl,--version-script=$(GRTSRCDIR)/grt.ver -Wl,--export-dynamic + + mmap_binding.o: ortho/mmap_binding.c + $(CC) -c -g -o $@ $< diff --git a/scripts/ghdl_version.diff b/patches/ghdl/ghdl_version.patch similarity index 100% rename from scripts/ghdl_version.diff rename to patches/ghdl/ghdl_version.patch diff --git a/scripts/libghdl_static.diff b/patches/ghdl/libghdl_static.patch similarity index 100% rename from scripts/libghdl_static.diff rename to patches/ghdl/libghdl_static.patch diff --git a/scripts/yosys_ghdl.diff b/patches/yosys/yosys_ghdl.patch similarity index 100% rename from scripts/yosys_ghdl.diff rename to patches/yosys/yosys_ghdl.patch diff --git a/scripts/_common.sh b/scripts/_common.sh index abe577c..f1ffcfd 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -112,11 +112,15 @@ function strip_binaries() { then local dst_file=$PACKAGE_DIR/${NAME}_symbols/$path.dSYM dsymutil -o $dst_file $src_file - strip $src_file + if [ $STRIP_SYMBOLS == "1" ]; then + strip $src_file + fi else local dst_file=$PACKAGE_DIR/${NAME}_symbols/$path.debug objcopy --only-keep-debug "${src_file}" "${dst_file}" - strip $src_file --strip-debug --strip-unneeded + if [ $STRIP_SYMBOLS == "1" ]; then + strip $src_file --strip-debug --strip-unneeded + fi fi done } diff --git a/scripts/compile_ghdl.sh b/scripts/compile_ghdl.sh index 5813fec..42bb8a9 100755 --- a/scripts/compile_ghdl.sh +++ b/scripts/compile_ghdl.sh @@ -13,7 +13,8 @@ cd $BUILD_DIR/$dir_name # remove unwanted -lz linker flag on Darwin (because it causes a dynamic link) $SED -i 's/^[ \t]*pragma Linker_Options ("-lz");//;' ./src/grt/grt-zlib.ads # customise the version string for ghdl -patch -p1 < $WORK_DIR/scripts/ghdl_version.diff +patch -p1 < $WORK_DIR/patches/ghdl/ghdl_version.patch +patch -p1 < $WORK_DIR/patches/ghdl/ghdl_largs.patch export GHDL_DESC="$(git -C $UPSTREAM_DIR/$dir_name describe --dirty 2> /dev/null)" sed -i -e "s/@BUILDER@/open-tool-forge.$VERSION/" src/version.in diff --git a/scripts/compile_yosys.sh b/scripts/compile_yosys.sh index 09950f4..318897e 100755 --- a/scripts/compile_yosys.sh +++ b/scripts/compile_yosys.sh @@ -5,6 +5,7 @@ set -e -x dir_name=yosys commit=master +# commit=5eff0b73ae82ee490be3e732241eb22cb4bff952 git_url=https://github.com/YosysHQ/yosys.git dir_name_gyp=ghdl_yosys_plugin @@ -25,7 +26,7 @@ MAKEFILE_CONF_GHDL= GHDL_LDLIBS= if [ $COMPILE_GHDL == "1" ] then - patch < $WORK_DIR/scripts/yosys_ghdl.diff + patch < $WORK_DIR/patches/yosys/yosys_ghdl.patch mkdir -p frontends/ghdl cp -R ../$dir_name_gyp/src/* frontends/ghdl @@ -67,7 +68,9 @@ elif [ ${ARCH:0:7} == "windows" ]; then ARCHFLAGS=\"$ABC_ARCHFLAGS\" \ ABC_USE_NO_READLINE=1 \ ABC_USE_NO_PTHREADS=1 \ - ABC_USE_LIBSTDCXX=1" \ + ABC_USE_LIBSTDCXX=1 \ + OPTFLAGS=\"-ggdb -O0\" \ + ABC_MAKE_VERBOSE=1" \ ENABLE_TCL=0 ENABLE_PLUGINS=0 ENABLE_READLINE=0 ENABLE_COVER=0 ENABLE_ZLIB=0 ENABLE_ABC=1 \ PYTHON="./bin/python3-private.exe" # override the shebang telling the exe launcher where to find python From a12627a030e81aa9d23d75c14781e88942de6a56 Mon Sep 17 00:00:00 2001 From: Ed Bordin Date: Thu, 20 May 2021 12:53:26 +1000 Subject: [PATCH 2/3] #79 skip doc build for dfu-util to avoid pandoc dependency --- scripts/compile_dfu_util.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/compile_dfu_util.sh b/scripts/compile_dfu_util.sh index 38919e6..0465399 100755 --- a/scripts/compile_dfu_util.sh +++ b/scripts/compile_dfu_util.sh @@ -18,14 +18,14 @@ if [ $ARCH == "darwin" ]; then --includedir=/opt/local/include \ USB_CFLAGS="-I$LIBUSB_ROOT/include/libusb-1.0" \ USB_LIBS="$LIBUSB_ROOT/lib/libusb-1.0.a -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" - $MAKE + $MAKE SUBDIRS=src elif [ ${ARCH:0:7} = "windows" ] then ./configure USB_LIBS="-static -lpthread -lusb-1.0" - $MAKE + $MAKE SUBDIRS=src else ./configure USB_CFLAGS="-I$WORK_DIR/build-data/include/libusb-1.0" USB_LIBS="-static $WORK_DIR/build-data/lib/$ARCH/libusb-1.0.a -lpthread" - $MAKE + $MAKE SUBDIRS=src fi TOOLS="dfu-util dfu-prefix dfu-suffix" From 9e388b4d456df6aba55609d873faeee5a7d400db Mon Sep 17 00:00:00 2001 From: Ed Bordin Date: Thu, 20 May 2021 13:15:57 +1000 Subject: [PATCH 3/3] #79 try fix package install on msys2 --- scripts/install_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_dependencies.sh b/scripts/install_dependencies.sh index 22af2cf..dc77e7b 100755 --- a/scripts/install_dependencies.sh +++ b/scripts/install_dependencies.sh @@ -81,7 +81,7 @@ if [ $ARCH == "windows_x86" ]; then fi if [ $ARCH == "windows_amd64" ]; then - pacman --noconfirm --needed -S git base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake \ + pacman --noconfirm --needed --refresh --sync -S git base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake \ mingw-w64-x86_64-boost mingw-w64-x86_64-eigen3 rsync unzip zip mingw-w64-x86_64-libftdi bison flex \ mingw-w64-x86_64-gcc-ada p7zip mingw-w64-x86_64-jsoncpp