From 09b9aa83c9ec7c1e7cf64ae267d5947c4b962b9a Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Fri, 12 Apr 2024 07:08:18 +0200 Subject: [PATCH 1/4] Add YosysHQ/abc as a submodule located in abc --- .github/workflows/codeql.yml | 3 +- .github/workflows/emcc.yml | 2 ++ .github/workflows/test-docs.yml | 3 +- .github/workflows/test-linux.yml | 3 +- .github/workflows/test-macos.yml | 3 +- .github/workflows/test-verific.yml | 2 +- .github/workflows/version.yml | 1 + .github/workflows/vs.yml | 6 ++-- .github/workflows/wasi.yml | 2 ++ .gitignore | 2 +- .gitmodules | 3 ++ Makefile | 56 ++++++------------------------ abc | 1 + 13 files changed, 33 insertions(+), 54 deletions(-) create mode 100644 .gitmodules create mode 160000 abc diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4a77d223429..24ae7c89883 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -15,7 +15,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - + with: + submodules: true - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: diff --git a/.github/workflows/emcc.yml b/.github/workflows/emcc.yml index 7c6409c1be2..b883cfa0a8a 100644 --- a/.github/workflows/emcc.yml +++ b/.github/workflows/emcc.yml @@ -8,6 +8,8 @@ jobs: steps: - uses: mymindstorm/setup-emsdk@v14 - uses: actions/checkout@v4 + with: + submodules: true - name: Build run: | make config-emcc diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index 00e5309bfbe..f6bcd33eb1b 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/test-docs.yml @@ -29,7 +29,8 @@ jobs: - name: Checkout Yosys uses: actions/checkout@v3 - + with: + submodules: true - name: Build yosys shell: bash run: | diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index c4441a8843e..a75873d8995 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -80,7 +80,8 @@ jobs: - name: Checkout Yosys uses: actions/checkout@v4 - + with: + submodules: true - name: Get iverilog shell: bash run: | diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 8ca658c3951..37b66df9bec 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -36,7 +36,8 @@ jobs: - name: Checkout Yosys uses: actions/checkout@v4 - + with: + submodules: true - name: Get iverilog shell: bash run: | diff --git a/.github/workflows/test-verific.yml b/.github/workflows/test-verific.yml index b4383eba462..ef7fa3829d8 100644 --- a/.github/workflows/test-verific.yml +++ b/.github/workflows/test-verific.yml @@ -10,7 +10,7 @@ jobs: uses: actions/checkout@v4 with: persist-credentials: false - + submodules: true - name: Runtime environment run: | echo "procs=$(nproc)" >> $GITHUB_ENV diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 47a7fe1a39f..f73c68bdf12 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -13,6 +13,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + submodules: true - name: Take last commit id: log run: echo "message=$(git log --no-merges -1 --oneline)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/vs.yml b/.github/workflows/vs.yml index 799c5f259f4..0647cff1a34 100644 --- a/.github/workflows/vs.yml +++ b/.github/workflows/vs.yml @@ -7,17 +7,19 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Build run: make vcxsrc YOSYS_VER=latest - uses: actions/upload-artifact@v4 with: name: vcxsrc path: yosys-win32-vcxsrc-latest.zip - + build: runs-on: windows-2019 needs: yosys-vcxsrc - steps: + steps: - uses: actions/download-artifact@v4 with: name: vcxsrc diff --git a/.github/workflows/wasi.yml b/.github/workflows/wasi.yml index d6d200d92c2..d65a9622799 100644 --- a/.github/workflows/wasi.yml +++ b/.github/workflows/wasi.yml @@ -7,6 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Build run: | WASI_SDK=wasi-sdk-19.0 diff --git a/.gitignore b/.gitignore index 6e4ffea4203..b4797d63884 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ __pycache__ /coverage.info /coverage_html /Makefile.conf -/abc /viz.js /yosys /yosys.exe @@ -46,3 +45,4 @@ __pycache__ /tests/unit/bintest/ /tests/unit/objtest/ /tests/ystests +/build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..d88d4b1e5e9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "abc"] + path = abc + url = https://github.com/YosysHQ/abc diff --git a/Makefile b/Makefile index 55c6a3f02b0..5986539b6b9 100644 --- a/Makefile +++ b/Makefile @@ -160,15 +160,6 @@ OBJS = kernel/version_$(GIT_REV).o bumpversion: sed -i "/^YOSYS_VER := / s/+[0-9][0-9]*$$/+`git log --oneline c1ad377.. | wc -l`/;" Makefile -# set 'ABCREV = default' to use abc/ as it is -# -# Note: If you do ABC development, make sure that 'abc' in this directory -# is just a symlink to your actual ABC working directory, as 'make mrproper' -# will remove the 'abc' directory and you do not want to accidentally -# delete your work on ABC.. -ABCREV = 237d813 -ABCPULL = 1 -ABCURL ?= https://github.com/YosysHQ/abc ABCMKARGS = CC="$(CXX)" CXX="$(CXX)" ABC_USE_LIBSTDCXX=1 ABC_USE_NAMESPACE=abc VERBOSE=$(Q) # set ABCEXTERNAL = to use an external ABC instance @@ -789,41 +780,17 @@ $(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in -e 's#@BINDIR@#$(strip $(BINDIR))#;' -e 's#@DATDIR@#$(strip $(DATDIR))#;' < $< > $(PROGRAM_PREFIX)yosys-config $(Q) chmod +x $(PROGRAM_PREFIX)yosys-config -abc/abc-$(ABCREV)$(EXE) abc/libabc-$(ABCREV).a: +ABC_SOURCES := $(wildcard $(YOSYS_SRC)/abc/*) + +abc/abc$(EXE) abc/libabc.a: $(ABC_SOURCES) $(P) -ifneq ($(ABCREV),default) - $(Q) if test -d abc/.hg; then \ - echo 'REEBE: NOP qverpgbel vf n ut jbexvat pbcl! Erzbir nop/ naq er-eha "znxr".' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; false; \ - fi - $(Q) if test -d abc && test -d abc/.git && ! git -C abc diff-index --quiet HEAD; then \ - echo 'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; false; \ - fi - $(Q) if test -d abc && ! test -d abc/.git && ! test "`cat abc/.gitcommit | cut -c1-7`" = "$(ABCREV)"; then \ - echo 'REEBE: Qbjaybnqrq NOP irefvbaf qbrf abg zngpu! Qbjaybnq sebz:' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; echo $(ABCURL)/archive/$(ABCREV).tar.gz; false; \ - fi -# set a variable so the test fails if git fails to run - when comparing outputs directly, empty string would match empty string - $(Q) if test -d abc && ! test -d abc/.git && test "`cat abc/.gitcommit | cut -c1-7`" = "$(ABCREV)"; then \ - echo "Compiling local copy of ABC"; \ - elif ! (cd abc 2> /dev/null && rev="`git rev-parse $(ABCREV)`" && test "`git rev-parse HEAD`" = "$$rev"); then \ - test $(ABCPULL) -ne 0 || { echo 'REEBE: NOP abg hc gb qngr naq NOPCHYY frg gb 0 va Znxrsvyr!' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; exit 1; }; \ - echo "Pulling ABC from $(ABCURL):"; set -x; \ - test -d abc || git clone $(ABCURL) abc; \ - cd abc && $(MAKE) DEP= clean && git fetch $(ABCURL) && git checkout $(ABCREV); \ - fi -endif - $(Q) rm -f abc/abc-[0-9a-f]* - $(Q) $(MAKE) -C abc $(S) $(ABCMKARGS) $(if $(filter %.a,$@),PROG="abc-$(ABCREV)",PROG="abc-$(ABCREV)$(EXE)") MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: " $(if $(filter %.a,$@),libabc-$(ABCREV).a) - -ifeq ($(ABCREV),default) -.PHONY: abc/abc-$(ABCREV)$(EXE) -.PHONY: abc/libabc-$(ABCREV).a -endif - -$(PROGRAM_PREFIX)yosys-abc$(EXE): abc/abc-$(ABCREV)$(EXE) - $(P) cp abc/abc-$(ABCREV)$(EXE) $(PROGRAM_PREFIX)yosys-abc$(EXE) - -$(PROGRAM_PREFIX)yosys-libabc.a: abc/libabc-$(ABCREV).a - $(P) cp abc/libabc-$(ABCREV).a $(PROGRAM_PREFIX)yosys-libabc.a + $(Q) mkdir -p abc && $(MAKE) -C $(PROGRAM_PREFIX)abc -f "$(realpath $(YOSYS_SRC)/abc/Makefile)" ABCSRC="$(realpath $(YOSYS_SRC)/abc/)" $(S) $(ABCMKARGS) $(if $(filter %.a,$@),PROG="abc",PROG="abc$(EXE)") MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: " $(if $(filter %.a,$@),libabc.a) + +$(PROGRAM_PREFIX)yosys-abc$(EXE): abc/abc$(EXE) + $(P) cp abc/abc$(EXE) $(PROGRAM_PREFIX)yosys-abc$(EXE) + +$(PROGRAM_PREFIX)yosys-libabc.a: abc/libabc.a + $(P) cp abc/libabc.a $(PROGRAM_PREFIX)yosys-libabc.a ifneq ($(SEED),) SEEDOPT="-S $(SEED)" @@ -1141,9 +1108,6 @@ echo-yosys-ver: echo-git-rev: @echo "$(GIT_REV)" -echo-abc-rev: - @echo "$(ABCREV)" - echo-cxx: @echo "$(CXX)" diff --git a/abc b/abc new file mode 160000 index 00000000000..237d81397fc --- /dev/null +++ b/abc @@ -0,0 +1 @@ +Subproject commit 237d81397fcc85dd3894bf1a449d2955cd3df02d From 67d4c8bba664f98b4ada2770c648376d92714f35 Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Fri, 12 Apr 2024 07:24:45 +0200 Subject: [PATCH 2/4] Use $< to refer to the first prerequisite listed in the rule --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5986539b6b9..2188c52e112 100644 --- a/Makefile +++ b/Makefile @@ -787,10 +787,10 @@ abc/abc$(EXE) abc/libabc.a: $(ABC_SOURCES) $(Q) mkdir -p abc && $(MAKE) -C $(PROGRAM_PREFIX)abc -f "$(realpath $(YOSYS_SRC)/abc/Makefile)" ABCSRC="$(realpath $(YOSYS_SRC)/abc/)" $(S) $(ABCMKARGS) $(if $(filter %.a,$@),PROG="abc",PROG="abc$(EXE)") MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: " $(if $(filter %.a,$@),libabc.a) $(PROGRAM_PREFIX)yosys-abc$(EXE): abc/abc$(EXE) - $(P) cp abc/abc$(EXE) $(PROGRAM_PREFIX)yosys-abc$(EXE) + $(P) cp $< $(PROGRAM_PREFIX)yosys-abc$(EXE) $(PROGRAM_PREFIX)yosys-libabc.a: abc/libabc.a - $(P) cp abc/libabc.a $(PROGRAM_PREFIX)yosys-libabc.a + $(P) cp $< $(PROGRAM_PREFIX)yosys-libabc.a ifneq ($(SEED),) SEEDOPT="-S $(SEED)" From fdbe8714c9337e8125470c9d4bc28e9b141e3997 Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Fri, 12 Apr 2024 14:29:05 +0200 Subject: [PATCH 3/4] Check that abc is checkout out as a git repo --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2188c52e112..e7a1248c46c 100644 --- a/Makefile +++ b/Makefile @@ -780,9 +780,20 @@ $(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in -e 's#@BINDIR@#$(strip $(BINDIR))#;' -e 's#@DATDIR@#$(strip $(DATDIR))#;' < $< > $(PROGRAM_PREFIX)yosys-config $(Q) chmod +x $(PROGRAM_PREFIX)yosys-config +.PHONY: check-git-abc + +check-git-abc: + @if [ -f "$(YOSYS_SRC)/abc/.git" ]; then \ + echo "abc/.git exists"; \ + exit 0; \ + else \ + echo "abc/.git does not exist. Please execute git submodule update --init"; \ + exit 1; \ + fi + ABC_SOURCES := $(wildcard $(YOSYS_SRC)/abc/*) -abc/abc$(EXE) abc/libabc.a: $(ABC_SOURCES) +abc/abc$(EXE) abc/libabc.a: $(ABC_SOURCES) check-git-abc $(P) $(Q) mkdir -p abc && $(MAKE) -C $(PROGRAM_PREFIX)abc -f "$(realpath $(YOSYS_SRC)/abc/Makefile)" ABCSRC="$(realpath $(YOSYS_SRC)/abc/)" $(S) $(ABCMKARGS) $(if $(filter %.a,$@),PROG="abc",PROG="abc$(EXE)") MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: " $(if $(filter %.a,$@),libabc.a) From 6d181c29ce05323fe1515e3dea7cb43ed8167773 Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Sun, 14 Apr 2024 19:56:07 +0200 Subject: [PATCH 4/4] Checking different cases for abc --- Makefile | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e7a1248c46c..46778b6d53a 100644 --- a/Makefile +++ b/Makefile @@ -783,12 +783,24 @@ $(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in .PHONY: check-git-abc check-git-abc: - @if [ -f "$(YOSYS_SRC)/abc/.git" ]; then \ - echo "abc/.git exists"; \ - exit 0; \ - else \ - echo "abc/.git does not exist. Please execute git submodule update --init"; \ + @if [ ! -d "$(YOSYS_SRC)/abc" ]; then \ + echo "Error: The 'abc' directory does not exist."; \ + echo "Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ + exit 1; \ + elif git -C "$(YOSYS_SRC)" submodule status abc 2>/dev/null | grep -q '^ '; then \ + echo "'abc' is a git submodule. Continuing."; \ + exit 0; \ + elif [ -f "$(YOSYS_SRC)/abc/.gitcommit" ] && grep -q '\$$Format:%h\$$' "$(YOSYS_SRC)/abc/.gitcommit"; then \ + echo "Error: 'abc' is not configured as a git submodule."; \ + echo "To resolve this:"; \ + echo "1. Back up your changes: Save any modifications from the 'abc' directory to another location."; \ + echo "2. Remove the existing 'abc' directory: Delete the 'abc' directory and all its contents."; \ + echo "3. Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ + echo "4. Reapply your changes: Move your saved changes back to the 'abc' directory, if necessary."; \ exit 1; \ + else \ + echo "'abc' comes from a tarball. Continuing."; \ + exit 0; \ fi ABC_SOURCES := $(wildcard $(YOSYS_SRC)/abc/*)