Travis: Add FreeBSD build + portability fixes

This commit is contained in:
Geza Lore 2020-06-04 21:08:32 +01:00
parent 98b5417e04
commit 378d947702
8 changed files with 100 additions and 16 deletions

View File

@ -17,6 +17,8 @@ cache:
env:
global:
- VERILATOR_ROOT=$TRAVIS_BUILD_DIR
# Hack around debug mode issues on FreeBSD
- ENV_HACK=$([ ! -e $TRAVIS_BUILD_DIR/ci/travis-env-hack.bash ] || $TRAVIS_BUILD_DIR/ci/travis-env-hack.bash)
# The list and order of build stages
stages:
@ -41,6 +43,8 @@ install:
before_script:
# ccache maintenance
- ./ci/travis-ccache-maint.bash
# Don't produce core dumps (esp. on FreeBSD)
- ulimit -c 0
# On Focal, set the SystemC installation location
- |
if [ "$TRAVIS_DIST" = "focal" ]; then
@ -72,6 +76,8 @@ jobs:
- {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: .}}}
# FreeBSD build
- {stage: build, if: type = cron, os: freebsd, compiler: clang, workspaces: {create: {name: freebsd, paths: .}}}
############################################################################
# Jobs in the 'test' stage
############################################################################
@ -116,6 +122,11 @@ jobs:
- {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}
# FreeBSD tests - Note these need the git clone in order to pick up the ENV_HACK
- {stage: test, if: type = cron, os: freebsd, compiler: clang, workspaces: {use: freebsd}, git: {clone: true}, env: TESTS=dist-vlt-0}
- {stage: test, if: type = cron, os: freebsd, compiler: clang, workspaces: {use: freebsd}, git: {clone: true}, env: TESTS=dist-vlt-1}
- {stage: test, if: type = cron, os: freebsd, compiler: clang, workspaces: {use: freebsd}, git: {clone: true}, env: TESTS=vltmt-0}
- {stage: test, if: type = cron, os: freebsd, compiler: clang, workspaces: {use: freebsd}, git: {clone: true}, env: TESTS=vltmt-1}
notifications:
email:

37
ci/travis-env-hack.bash Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
# DESCRIPTION: Verilator: Travis CI early platform workaround
#
# Copyright 2020 by Geza Lore. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
################################################################################
# This script runs very early by setting an env variable to $(<this script>)
# This is to work around travis-ci issues
################################################################################
set -e
set -x
if [ "$TRAVIS_OS_NAME" = "freebsd" ]; then
# Needs bash in bin for non-portable #! in scripts
sudo ln -s "$(which bash)" /bin/bash
# Needs tmate for debug mode (the one in pkg is too old, so build from source)
sudo pkg install -y libevent
sudo pkg install -y msgpack
sudo pkg install -y libssh
git clone https://github.com/tmate-io/tmate.git /tmp/tmate-build
pushd /tmp/tmate-build
git checkout 2.4.0
./autogen.sh
./configure
make -j$(sysctl -n hw.ncpu)
sudo make install
popd
# Travis debug scripts also require this to be in /usr/bin rather than
# /usr/local/bin whre the abote puts it
sudo ln -s "$(which tmate)" /usr/bin/tmate
fi

View File

@ -25,11 +25,21 @@ fatal() {
echo "ERROR: $(basename "$0"): $1" >&2; exit 1;
}
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
MAKE=make
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
MAKE=make
elif [ "$TRAVIS_OS_NAME" = "freebsd" ]; then
MAKE=gmake
else
fatal "Unknown os: '$TRAVIS_OS_NAME'"
fi
install-vcddiff() {
TMP_DIR="$(mktemp -d)"
git clone https://github.com/veripool/vcddiff "$TMP_DIR"
git -C "${TMP_DIR}" checkout 5112f88b7ba8818dce9dfb72619e64a1fc19542c
make -C "${TMP_DIR}"
"$MAKE" -C "${TMP_DIR}"
sudo cp "${TMP_DIR}/vcddiff" /usr/local/bin
}
@ -48,6 +58,8 @@ if [ "$TRAVIS_BUILD_STAGE_NAME" = "build" ]; then
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew update
brew install ccache perl gperftools
elif [ "$TRAVIS_OS_NAME" = "freebsd" ]; then
sudo pkg install -y autoconf bison ccache gmake perl5
else
fatal "Unknown os: '$TRAVIS_OS_NAME'"
fi
@ -71,6 +83,11 @@ elif [ "$TRAVIS_BUILD_STAGE_NAME" = "test" ]; then
brew install ccache perl
yes yes | sudo cpan -fi Unix::Processors Parallel::Forker
install-vcddiff
elif [ "$TRAVIS_OS_NAME" = "freebsd" ]; then
# fst2vcd fails with "Could not open '<input file>', exiting."
sudo pkg install -y ccache gmake perl5 python3
yes yes | sudo cpan -fi Unix::Processors Parallel::Forker
install-vcddiff
else
fatal "Unknown os: '$TRAVIS_OS_NAME'"
fi

View File

@ -23,9 +23,14 @@ fatal() {
}
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
export MAKE=make
NPROC=$(nproc)
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
export MAKE=make
NPROC=$(sysctl -n hw.logicalcpu)
elif [ "$TRAVIS_OS_NAME" = "freebsd" ]; then
export MAKE=gmake
NPROC=$(sysctl -n hw.ncpu)
else
fatal "Unknown os: '$TRAVIS_OS_NAME'"
fi
@ -37,7 +42,7 @@ if [ "$TRAVIS_BUILD_STAGE_NAME" = "build" ]; then
if [ "$COVERAGE" != 1 ]; then
autoconf
./configure --enable-longtests --enable-ccwarn
make -j "$NPROC"
"$MAKE" -j "$NPROC"
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
file bin/verilator_bin
file bin/verilator_bin_dbg
@ -67,22 +72,25 @@ elif [ "$TRAVIS_BUILD_STAGE_NAME" = "test" ]; then
# it as data rather than a Mach-O). Unclear if this is an OS X issue or
# one for Travis. Remove the file and re-link...
rm bin/verilator_bin_dbg
make -j "$NPROC"
"$MAKE" -j "$NPROC"
elif [ "$TRAVIS_OS_NAME" = "freebsd" ]; then
export VERILATOR_TEST_NO_GDB=1 # Disable for now, ideally should run
export VERILATOR_TEST_NO_GPROF=1 # gprof is a bit different on FreeBSD, disable
fi
# Run the specified test
case $TESTS in
dist-vlt-0)
make -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=0/2
"$MAKE" -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=0/2
;;
dist-vlt-1)
make -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=1/2
"$MAKE" -C test_regress SCENARIOS="--dist --vlt" DRIVER_HASHSET=--hashset=1/2
;;
vltmt-0)
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
"$MAKE" -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
;;
vltmt-1)
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
"$MAKE" -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
;;
coverage-dist)
nodist/code_coverage --stages 3- --scenarios=--dist

View File

@ -3,7 +3,7 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). */
#if !defined(__MINGW32__)
#if !defined(__MINGW32__) && !defined(__FreeBSD__)
# define HAVE_ALLOCA_H 1
#endif

View File

@ -133,8 +133,6 @@ void VerilatedFst::declare(vluint32_t code, const char* name, int dtypenum, fstV
VerilatedTrace<VerilatedFst>::declCode(code, bits, false);
std::pair<Code2SymbolType::iterator, bool> p
= m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL)));
std::istringstream nameiss(name);
std::istream_iterator<std::string> beg(nameiss);
std::istream_iterator<std::string> end;
@ -174,11 +172,13 @@ void VerilatedFst::declare(vluint32_t code, const char* name, int dtypenum, fstV
fstEnumHandle enumNum = m_local2fstdtype[dtypenum];
fstWriterEmitEnumTableRef(m_fst, enumNum);
}
if (p.second) { // New
p.first->second = fstWriterCreateVar(m_fst, vartype, vardir, bits, name_str.c_str(), 0);
assert(p.first->second);
Code2SymbolType::const_iterator it = m_code2symbol.find(code);
if (it == m_code2symbol.end()) { // New
m_code2symbol[code]
= fstWriterCreateVar(m_fst, vartype, vardir, bits, name_str.c_str(), 0);
} else { // Alias
fstWriterCreateVar(m_fst, vartype, vardir, bits, name_str.c_str(), p.first->second);
fstWriterCreateVar(m_fst, vartype, vardir, bits, name_str.c_str(), it->second);
}
}

View File

@ -33,6 +33,7 @@
#include "V3Os.h"
#include <cerrno>
#include <climits> // PATH_MAX (especially on FreeBSD)
#include <cstdarg>
#include <dirent.h>
#include <fstream>

View File

@ -1075,6 +1075,15 @@ sub compile {
return 1;
}
if ($^O eq "freebsd") {
my $flags = join(' ', $self->compile_vlt_flags(%param));
if ($flags =~ /--trace-fst/ && $flags =~ /--trace-threads/) {
# See https://github.com/gtkwave/gtkwave/issues/24
$self->skip("Known fstapi.c threading issue on FreeBSD");
return 1;
}
}
if (!$param{fails} && $param{make_main}) {
$self->_make_main();
}
@ -2193,12 +2202,12 @@ sub fst2vcd {
my $fn1 = shift;
my $fn2 = shift;
if (!-r $fn1) { $self->error("File does not exist $fn1\n"); return 0; }
my $cmd = qq{fst2vcd --help};
my $cmd = qq{fst2vcd -h};
print "\t$cmd\n" if $::Debug;
my $out = `$cmd`;
if (!$out || $out !~ /Usage:/) { $self->skip("No fst2vcd installed\n"); return 1; }
$cmd = qq{fst2vcd -e "$fn1" -o "$fn2"};
$cmd = qq{fst2vcd -e -f "$fn1" -o "$fn2"};
print "\t$cmd\n"; # Always print to help debug race cases
$out = `$cmd`;
return 1;
@ -2208,6 +2217,7 @@ sub fst_identical {
my $self = (ref $_[0]? shift : $Self);
my $fn1 = shift;
my $fn2 = shift;
return 0 if $self->errors || $self->skips || $self->unsupporteds;
my $tmp = $fn1.".vcd";
fst2vcd($fn1, $tmp);
return vcd_identical($tmp, $fn2);