diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 611255f0d..b9a75a9bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -306,3 +306,34 @@ jobs: make simv VCS=verilator -j2 ./build/simv +workload=$WORKLOAD +b=0 +e=-1 +diff=$REF_SO +max-instrs=5000 +warmup_instr=1000 make clean + + test-difftest-xiangshan: + # ubuntu 22.04 has the same version of libc as our VCS machines + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + cd $GITHUB_WORKSPACE/.. + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/install-verilator.sh + wget https://github.com/OpenXiangShan/xs-env/raw/refs/heads/master/setup-tools.sh + sudo bash setup-tools.sh + + - name: Prepare XiangShan + run: | + cd $GITHUB_WORKSPACE/.. + git clone --depth 1 https://github.com/OpenXiangShan/XiangShan.git + cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE . + echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV + + - name: Chisel Elaboration + run: | + cd $NOOP_HOME + make sim-verilog CHISEL_TARGET=chirrtl JVM_XMX=10G + + - name: Build difftest-so + run: | + cd $NOOP_HOME + make -C difftest difftest-so diff --git a/libso.mk b/libso.mk index 332a75b87..c80ee0200 100644 --- a/libso.mk +++ b/libso.mk @@ -10,10 +10,26 @@ ifeq ($(WITH_DRAMSIM3),1) LD_LIB = -L $(DRAMSIM3_HOME)/ -ldramsim3 -Wl,-rpath-link=$(DRAMSIM3_HOME)/libdramsim3.so endif +# Include headers that are implicitly included by RTL simulators +# Priority: (1) VCS, (2) Verilator +ifneq ($(VCS_HOME),) +LIB_CXXFLAGS += -I$(VCS_HOME)/include +else +VERILATOR_ROOT = $(shell verilator -V 2>/dev/null | awk '/VERILATOR_ROOT/ {print $$3; exit}') +ifneq ($(VERILATOR_ROOT),) +LIB_CXXFLAGS += -I$(VERILATOR_ROOT)/include/vltstd +else +LIBSO_WARNING_MISSING_HEADERS = 1 +endif +endif + $(CC_OBJ_DIR): mkdir -p $(CC_OBJ_DIR) difftest-so: $(CC_OBJ_DIR) +ifeq ($(LIBSO_WARNING_MISSING_HEADERS),1) + @echo "No available RTL simulators. Headers may be missing. Still try to build it." +endif cd $(CC_OBJ_DIR) && \ $(CC) $(LIB_CXXFLAGS) $(LIB_CXXFILES) && \ $(CC) -o $(LIBDIFFTEST_SO) -m64 -shared *.o $(LD_LIB)