Travis: Add OS X build (#2440)

This commit is contained in:
Geza Lore 2020-06-22 10:13:54 +01:00 committed by GitHub
parent f13fd4478c
commit 5a4cc333fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 137 additions and 99 deletions

View File

@ -70,6 +70,8 @@ jobs:
- {stage: build, os: linux, dist: focal, compiler: clang, workspaces: {create: {name: focal-clang, paths: .}}} - {stage: build, os: linux, dist: focal, compiler: clang, workspaces: {create: {name: focal-clang, paths: .}}}
# Coverage build # Coverage build
- {stage: build, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {create: {name: coverage, paths: .}}, env: COVERAGE=1} - {stage: build, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {create: {name: coverage, paths: .}}, env: COVERAGE=1}
# OS X build
- {stage: build, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {create: {name: osx-xcode11.6, paths: .}}}
############################################################################ ############################################################################
# Jobs in the 'test' stage # Jobs in the 'test' stage
############################################################################ ############################################################################
@ -109,6 +111,11 @@ jobs:
- {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-1} - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-1}
- {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-2} - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-2}
- {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-3} - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-3}
# OS X tests
- {stage: test, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {use: osx-xcode11.6}, git: {clone: false}, env: TESTS=dist-vlt-0}
- {stage: test, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {use: osx-xcode11.6}, git: {clone: false}, env: TESTS=dist-vlt-1}
- {stage: test, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {use: osx-xcode11.6}, git: {clone: false}, env: TESTS=vltmt-0}
- {stage: test, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {use: osx-xcode11.6}, git: {clone: false}, env: TESTS=vltmt-1}
notifications: notifications:
email: email:

View File

@ -39,12 +39,15 @@ if [ "$TRAVIS_BUILD_STAGE_NAME" = "build" ]; then
# build Verilator # build Verilator
if [ "$TRAVIS_OS_NAME" = "linux" ]; then if [ "$TRAVIS_OS_NAME" = "linux" ]; then
time sudo apt-get update sudo apt-get update
sudo apt-get install libfl-dev sudo apt-get install libfl-dev
sudo apt-get install libgoogle-perftools-dev sudo apt-get install libgoogle-perftools-dev
if [ "$COVERAGE" = 1 ]; then if [ "$COVERAGE" = 1 ]; then
yes yes | sudo cpan -fi Unix::Processors Parallel::Forker yes yes | sudo cpan -fi Unix::Processors Parallel::Forker
fi fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew update
brew install ccache perl gperftools
else else
fatal "Unknown os: '$TRAVIS_OS_NAME'" fatal "Unknown os: '$TRAVIS_OS_NAME'"
fi fi
@ -62,6 +65,12 @@ elif [ "$TRAVIS_BUILD_STAGE_NAME" = "test" ]; then
yes yes | sudo cpan -fi Unix::Processors Parallel::Forker yes yes | sudo cpan -fi Unix::Processors Parallel::Forker
# Not listing Bit::Vector as slow to install, and only skips one test # Not listing Bit::Vector as slow to install, and only skips one test
install-vcddiff install-vcddiff
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew update
# brew cask install gtkwave # fst2vcd hangs at launch, so don't bother
brew install ccache perl
yes yes | sudo cpan -fi Unix::Processors Parallel::Forker
install-vcddiff
else else
fatal "Unknown os: '$TRAVIS_OS_NAME'" fatal "Unknown os: '$TRAVIS_OS_NAME'"
fi fi

View File

@ -22,77 +22,85 @@ fatal() {
echo "ERROR: $(basename "$0"): $1" >&2; exit 1; echo "ERROR: $(basename "$0"): $1" >&2; exit 1;
} }
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
NPROC=$(nproc)
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
NPROC=$(sysctl -n hw.logicalcpu)
else
fatal "Unknown os: '$TRAVIS_OS_NAME'"
fi
if [ "$TRAVIS_BUILD_STAGE_NAME" = "build" ]; then if [ "$TRAVIS_BUILD_STAGE_NAME" = "build" ]; then
############################################################################## ##############################################################################
# Build verilator # Build verilator
if [ "$TRAVIS_OS_NAME" = "linux" ]; then if [ "$COVERAGE" != 1 ]; then
if [ "$COVERAGE" != 1 ]; then autoconf
autoconf ./configure --enable-longtests --enable-ccwarn
./configure --enable-longtests --enable-ccwarn make -j "$NPROC"
make -j $(nproc) file bin/verilator_bin
else file bin/verilator_bin_dbg
nodist/code_coverage --stages 1-2
fi
else else
fatal "Unknown os: '$TRAVIS_OS_NAME'" nodist/code_coverage --stages 1-2
fi fi
elif [ "$TRAVIS_BUILD_STAGE_NAME" = "test" ]; then elif [ "$TRAVIS_BUILD_STAGE_NAME" = "test" ]; then
############################################################################## ##############################################################################
# Run tests # Run tests
if [ "$TRAVIS_OS_NAME" = "linux" ]; then if [ "$TRAVIS_OS_NAME" = "osx" ]; then
# Run the specified test export VERILATOR_TEST_NO_GDB=1 # Pain to get GDB to work on OS X
case $TESTS in export VERILATOR_TEST_NO_GPROF=1 # Apple Clang has no -pg
dist-vlt-0) # export PATH="/Applications/gtkwave.app/Contents/Resources/bin:$PATH" # fst2vcd
make -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=0/2 fi
;;
dist-vlt-1) # Run the specified test
make -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=1/2 case $TESTS in
;; dist-vlt-0)
vltmt-0) make -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=0/2
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2 ;;
;; dist-vlt-1)
vltmt-1) make -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=1/2
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2 ;;
;; vltmt-0)
coverage-dist) make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
nodist/code_coverage --stages 3- --scenarios=--dist ;;
;; vltmt-1)
coverage-vlt-0) make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=0/4 ;;
;; coverage-dist)
coverage-vlt-1) nodist/code_coverage --stages 3- --scenarios=--dist
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=1/4 ;;
;; coverage-vlt-0)
coverage-vlt-2) nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=0/4
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=2/4 ;;
;; coverage-vlt-1)
coverage-vlt-3) nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=1/4
nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=3/4 ;;
;; coverage-vlt-2)
coverage-vltmt-0) nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=2/4
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=0/4 ;;
;; coverage-vlt-3)
coverage-vltmt-1) nodist/code_coverage --stages 3- --scenarios=--vlt --hashset=3/4
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=1/4 ;;
;; coverage-vltmt-0)
coverage-vltmt-2) nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=0/4
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=2/4 ;;
;; coverage-vltmt-1)
coverage-vltmt-3) nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=1/4
nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=3/4 ;;
;; coverage-vltmt-2)
*) nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=2/4
fatal "Unknown test: $TESTS" ;;
;; coverage-vltmt-3)
esac nodist/code_coverage --stages 3- --scenarios=--vltmt --hashset=3/4
# Upload coverage data to codecov.io ;;
if [[ $TESTS == coverage-* ]]; then *)
bash <(curl -s https://codecov.io/bash) -f nodist/obj_dir/coverage/app_total.info fatal "Unknown test: $TESTS"
fi ;;
else esac
fatal "Unknown os: '$TRAVIS_OS_NAME'" # Upload coverage data to codecov.io
if [[ $TESTS == coverage-* ]]; then
bash <(curl -s https://codecov.io/bash) -f nodist/obj_dir/coverage/app_total.info
fi fi
else else
############################################################################## ##############################################################################

View File

@ -128,12 +128,6 @@ AC_ARG_ENABLE([prec11],
AC_SUBST(CFG_WITH_PREC11) AC_SUBST(CFG_WITH_PREC11)
AC_MSG_RESULT($CFG_WITH_PREC11) AC_MSG_RESULT($CFG_WITH_PREC11)
# Compiler flags
CFLAGS+=" -I${includedir}"
CPPFLAGS+=" -I${includedir}"
CXXFLAGS+=" -I${includedir}"
LDFLAGS+=" -L${libdir}"
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
AC_PROG_CXX AC_PROG_CXX

View File

@ -68,7 +68,7 @@ run:
@echo " library (libverilated_secret.a) generated from the previous" @echo " library (libverilated_secret.a) generated from the previous"
@echo " step" @echo " step"
@echo "---------------------------------------------------------------" @echo "---------------------------------------------------------------"
$(VERILATOR) $(TOP_VERILATOR_FLAGS) --exe -LDFLAGS '-L../obj_dir_secret -lverilated_secret -static' top.v obj_dir_secret/verilated_secret.sv sim_main.cpp $(VERILATOR) $(TOP_VERILATOR_FLAGS) --exe -LDFLAGS '../obj_dir_secret/libverilated_secret.a' top.v obj_dir_secret/verilated_secret.sv sim_main.cpp
@echo @echo
@echo "-- COMPILE entire design --------------------------------------" @echo "-- COMPILE entire design --------------------------------------"

View File

@ -278,7 +278,6 @@ V3__CONCAT.cpp: $(addsuffix .cpp, $(basename $(RAW_OBJS)))
$(TGT): $(PREDEP_H) $(OBJS) $(TGT): $(PREDEP_H) $(OBJS)
@echo " Linking $@..." @echo " Linking $@..."
-rm -rf $@ $@.exe
${LINK} ${LDFLAGS} -o $@ $(OBJS) $(CCMALLOC) ${LIBS} ${LINK} ${LDFLAGS} -o $@ $(OBJS) $(CCMALLOC) ${LIBS}
V3Number_test: V3Number_test.o V3Number_test: V3Number_test.o

View File

@ -9,35 +9,43 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt_all => 1); scenarios(vlt_all => 1);
top_filename("t/t_case_huge.v"); top_filename("t/t_case_huge.v");
compile( if ($ENV{VERILATOR_TEST_NO_GPROF}) {
verilator_flags2 => ["--stats --prof-cfuncs -CFLAGS '-pg' -LDFLAGS '-pg'"], skip("Skipping due to VERILATOR_TEST_NO_GPROF");
); } else {
dotest();
file_grep($Self->{stats}, qr/Optimizations, Tables created\s+(\d+)/i, 10); }
file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 10);
unlink $_ foreach (glob "$Self->{obj_dir}/gmon.out.*");
setenv('GMON_OUT_PREFIX', "$Self->{obj_dir}/gmon.out");
execute(
check_finished => 1,
);
my $gmon_path;
$gmon_path = $_ foreach (glob "$Self->{obj_dir}/gmon.out.*");
$gmon_path or error("Profiler did not create a gmon.out");
(my $gmon_base = $gmon_path) =~ s!.*[/\\]!!;
run(cmd => ["cd $Self->{obj_dir} && gprof $Self->{VM_PREFIX} $gmon_base > gprof.out"],
check_finished => 0);
run(cmd => ["cd $Self->{obj_dir} && $ENV{VERILATOR_ROOT}/bin/verilator_profcfunc gprof.out > cfuncs.out"],
check_finished => 0);
file_grep("$Self->{obj_dir}/cfuncs.out", qr/Overall summary by/);
ok(1); ok(1);
sub dotest {
compile(
verilator_flags2 => ["--stats --prof-cfuncs -CFLAGS '-pg' -LDFLAGS '-pg'"],
);
file_grep($Self->{stats}, qr/Optimizations, Tables created\s+(\d+)/i, 10);
file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 10);
unlink $_ foreach (glob "$Self->{obj_dir}/gmon.out.*");
setenv('GMON_OUT_PREFIX', "$Self->{obj_dir}/gmon.out");
execute(
check_finished => 1,
);
my $gmon_path;
$gmon_path = $_ foreach (glob "$Self->{obj_dir}/gmon.out.*");
$gmon_path or error("Profiler did not create a gmon.out");
(my $gmon_base = $gmon_path) =~ s!.*[/\\]!!;
run(cmd => ["cd $Self->{obj_dir} && gprof $Self->{VM_PREFIX} $gmon_base > gprof.out"],
check_finished => 0);
run(cmd => ["cd $Self->{obj_dir} && $ENV{VERILATOR_ROOT}/bin/verilator_profcfunc gprof.out > cfuncs.out"],
check_finished => 0);
file_grep("$Self->{obj_dir}/cfuncs.out", qr/Overall summary by/);
}
1; 1;

View File

@ -28,6 +28,19 @@ compile(
"t_flag_ldflags_so.so",], "t_flag_ldflags_so.so",],
); );
# On OS X, LD_LIBRARY_PATH is ignored, so set rpath of the exe to find the .so
if ($^O eq "darwin") {
run(cmd => ["cd $Self->{obj_dir}"
." && install_name_tool -add_rpath \@executable_path/."
." $Self->{VM_PREFIX}"],
check_finished => 0);
run(cmd => ["cd $Self->{obj_dir}"
." && install_name_tool -change t_flag_ldflags_so.so"
." \@rpath/t_flag_ldflags_so.so $Self->{VM_PREFIX}"],
check_finished => 0);
}
execute( execute(
check_finished => 1, check_finished => 1,
run_env => "LD_LIBRARY_PATH=$Self->{obj_dir}", run_env => "LD_LIBRARY_PATH=$Self->{obj_dir}",

View File

@ -51,7 +51,7 @@ while (1) {
compile( compile(
verilator_flags2 => ["$secret_dir/secret.sv", verilator_flags2 => ["$secret_dir/secret.sv",
"-LDFLAGS", "-LDFLAGS",
"'-L$secret_prefix -lsecret -static'"], "$secret_prefix/libsecret.a"],
xsim_flags2 => ["$secret_dir/secret.sv"], xsim_flags2 => ["$secret_dir/secret.sv"],
); );

View File

@ -54,7 +54,7 @@ while (1) {
verilator_flags2 => ["$secret_dir/secret.sv", verilator_flags2 => ["$secret_dir/secret.sv",
"-GGATED_CLK=1", "-GGATED_CLK=1",
"-LDFLAGS", "-LDFLAGS",
"'-L$secret_prefix -lsecret -static'"], "$secret_prefix/libsecret.a"],
xsim_flags2 => ["$secret_dir/secret.sv"], xsim_flags2 => ["$secret_dir/secret.sv"],
); );