Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: switch to gcc 10.2.1 for master builds #18113

Merged
merged 8 commits into from Jul 27, 2021
Merged
8 changes: 8 additions & 0 deletions Tools/ardupilotwaf/boards.py
Expand Up @@ -156,6 +156,13 @@ def configure_env(self, cfg, env):

cfg.msg("CXX Compiler", "%s %s" % (cfg.env.COMPILER_CXX, ".".join(cfg.env.CC_VERSION)))

if cfg.options.assert_cc_version:
cfg.msg("Checking compiler", "%s %s" % (cfg.options.assert_cc_version, ".".join(cfg.env.CC_VERSION)))
have_version = cfg.env.COMPILER_CXX+"-"+'.'.join(list(cfg.env.CC_VERSION))
want_version = cfg.options.assert_cc_version
if have_version != want_version:
cfg.fatal("cc version mismatch: %s should be %s" % (have_version, want_version))

if 'clang' in cfg.env.COMPILER_CC:
env.CFLAGS += [
'-fcolor-diagnostics',
Expand Down Expand Up @@ -762,6 +769,7 @@ def configure_env(self, cfg, env):
('6','3','1'),
('9','2','1'),
('9','3','1'),
('10','2','1'),
]

if cfg.options.Werror or cfg.env.CC_VERSION in gcc_whitelist:
Expand Down
2 changes: 1 addition & 1 deletion Tools/debug/README.md
Expand Up @@ -22,7 +22,7 @@ your black magic probe, or install the provided udev rules file so
that the probe will be loaded as /dev/ttyBmpGdb

Now make sure you have the right version of arm-none-eabi-gdb
installed. We recommend version 6-2017-q2-update, which is available
installed. We recommend version 10-2020-q4-major, which is available
here: https://firmware.ardupilot.org/Tools/STM32-tools/

Now build ArduPilot with the --debug configure option. You may also
Expand Down
4 changes: 2 additions & 2 deletions Tools/environment_install/install-prereqs-arch.sh
Expand Up @@ -14,8 +14,8 @@ PYTHON3_PKGS="pyserial empy geocoder"

# GNU Tools for ARM Embedded Processors
# (see https://launchpad.net/gcc-arm-embedded/)
ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update"
ARM_TARBALL="$ARM_ROOT-linux.tar.bz2"
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"
ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"

# Ardupilot Tools
Expand Down
2 changes: 1 addition & 1 deletion Tools/environment_install/install-prereqs-mac.sh
Expand Up @@ -62,7 +62,7 @@ fi
function install_arm_none_eabi_toolchain() {
# GNU Tools for ARM Embedded Processors
# (see https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update"
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
ARM_TARBALL="$ARM_ROOT-mac.tar.bz2"
ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"
if [ ! -d $OPT/$ARM_ROOT ]; then
Expand Down
4 changes: 2 additions & 2 deletions Tools/environment_install/install-prereqs-ubuntu.sh
Expand Up @@ -142,8 +142,8 @@ fi
function install_arm_none_eabi_toolchain() {
# GNU Tools for ARM Embedded Processors
# (see https://launchpad.net/gcc-arm-embedded/)
ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update"
ARM_TARBALL="$ARM_ROOT-linux.tar.bz2"
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"
ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"
if [ ! -d $OPT/$ARM_ROOT ]; then
(
Expand Down
162 changes: 52 additions & 110 deletions Tools/scripts/build_binaries.py
Expand Up @@ -32,6 +32,28 @@
running_python3 = True


def is_chibios_build(board):
'''see if a board is using HAL_ChibiOS'''
hwdef_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "libraries", "AP_HAL_ChibiOS", "hwdef")
return os.path.exists(os.path.join(hwdef_dir, board, "hwdef.dat"))


def get_required_compiler(tag, board):
'''return required compiler for a build tag.
return format is the version string that waf configure will detect.
You should setup a link from this name in $HOME/arm-gcc directory pointing at the
appropriate compiler
'''
if not is_chibios_build(board):
# only override compiler for ChibiOS builds
return None
if tag == 'latest':
# use 10.2.1 compiler for master builds
return "g++-10.2.1"
# for all other builds we use the default compiler in $PATH
return None


class build_binaries(object):
def __init__(self, tags):
self.tags = tags
Expand Down Expand Up @@ -62,21 +84,34 @@ def board_options(self, board):
return ["--static"]
return []

def run_waf(self, args):
def run_waf(self, args, compiler=None):
if os.path.exists("waf"):
waf = "./waf"
else:
waf = os.path.join(".", "modules", "waf", "waf-light")
cmd_list = [waf]
cmd_list.extend(args)
self.run_program("BB-WAF", cmd_list)
env = None
if compiler is not None:
# default to $HOME/arm-gcc, but allow for any path with AP_GCC_HOME environment variable
gcc_home = os.environ.get("AP_GCC_HOME", os.path.join(os.environ["HOME"], "arm-gcc"))
gcc_path = os.path.join(gcc_home, compiler, "bin")
if os.path.exists(gcc_path):
# setup PATH to point at the right compiler, and setup to use ccache
env = os.environ.copy()
env["PATH"] = gcc_path + ":" + env["PATH"]
env["CC"] = "ccache arm-none-eabi-gcc"
env["CXX"] = "ccache arm-none-eabi-g++"
else:
raise Exception("BB-WAF: Missing compiler %s" % gcc_path)
self.run_program("BB-WAF", cmd_list, env=env)

def run_program(self, prefix, cmd_list, show_output=True):
def run_program(self, prefix, cmd_list, show_output=True, env=None):
if show_output:
self.progress("Running (%s)" % " ".join(cmd_list))
p = subprocess.Popen(cmd_list, bufsize=1, stdin=None,
stdout=subprocess.PIPE, close_fds=True,
stderr=subprocess.STDOUT)
stderr=subprocess.STDOUT, env=env)
output = ""
while True:
x = p.stdout.readline()
Expand Down Expand Up @@ -164,7 +199,7 @@ def checkout(self, vehicle, ctag, cboard=None, cframe=None, submodule_update=Tru
return False

def skip_board_waf(self, board):
'''check if we should skip this build because we don't support the
'''check if we should skip this build because we do not support the
board in this release
'''

Expand Down Expand Up @@ -347,7 +382,7 @@ def touch_filepath(self, filepath):
pass

def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir,
binaryname, px4_binaryname, frames=[None]):
binaryname, frames=[None]):
'''build vehicle binaries'''
self.progress("Building %s %s binaries (cwd=%s)" %
(vehicle, tag, os.getcwd()))
Expand Down Expand Up @@ -409,15 +444,19 @@ def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir,
"--board", board,
"--out", self.buildroot,
"clean"]
gccstring = get_required_compiler(tag, board)
if gccstring is not None:
waf_opts += ["--assert-cc-version", gccstring]

waf_opts.extend(self.board_options(board))
self.run_waf(waf_opts)
self.run_waf(waf_opts, compiler=gccstring)
except subprocess.CalledProcessError:
self.progress("waf configure failed")
continue
try:
target = os.path.join("bin",
"".join([binaryname, framesuffix]))
self.run_waf(["build", "--targets", target])
self.run_waf(["build", "--targets", target], compiler=gccstring)
except subprocess.CalledProcessError:
msg = ("Failed build of %s %s%s %s" %
(vehicle, board, framesuffix, tag))
Expand All @@ -439,7 +478,7 @@ def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir,
"bin",
"".join([binaryname, framesuffix]))
files_to_copy = []
extensions = [".px4", ".apj", ".abin", "_with_bl.hex", ".hex"]
extensions = [".apj", ".abin", "_with_bl.hex", ".hex"]
if vehicle == 'AP_Periph':
# need bin file for uavcan-gui-tool and MissionPlanner
extensions.append('.bin')
Expand All @@ -465,97 +504,6 @@ def build_vehicle(self, tag, vehicle, boards, vehicle_binaries_subdir,
# record some history about this build
self.history.record_build(githash, tag, vehicle, board, frame, bare_path, t0, time_taken_to_build)

if not self.checkout(vehicle, tag, "PX4", None):
tridge marked this conversation as resolved.
Show resolved Hide resolved
self.checkout(vehicle, "latest")
return

board_list = self.run_program('BB-WAF', ['./waf', 'list_boards'])
board_list = board_list.split(' ')
self.checkout(vehicle, "latest")
if 'px4-v2' not in board_list:
print("Skipping px4 builds")
return

# PX4-building
board = "px4"
for frame in frames:
self.progress("Building frame %s for board %s" % (frame, board))
if frame is None:
framesuffix = ""
else:
framesuffix = "-%s" % frame

if not self.checkout(vehicle, tag, "PX4", frame):
msg = ("Failed checkout of %s %s %s %s" %
(vehicle, "PX4", tag, frame))
self.progress(msg)
self.error_strings.append(msg)
self.checkout(vehicle, "latest")
continue

try:
deadwood = "../Build.%s" % vehicle
if os.path.exists(deadwood):
self.progress("#### Removing (%s)" % deadwood)
shutil.rmtree(os.path.join(deadwood))
except Exception as e:
self.progress("FIXME: narrow exception (%s)" % repr(e))

self.progress("Building %s %s PX4%s binaries" %
(vehicle, tag, framesuffix))
ddir = os.path.join(self.binaries,
vehicle_binaries_subdir,
self.hdate_ym,
self.hdate_ymdhm,
"".join(["PX4", framesuffix]))
if self.skip_build(tag, ddir):
continue

for v in ["v1", "v2", "v3", "v4", "v4pro"]:
px4_v = "%s-%s" % (board, v)

if self.skip_board_waf(px4_v):
continue

if os.path.exists(self.buildroot):
shutil.rmtree(self.buildroot)

self.progress("Configuring for %s in %s" %
(px4_v, self.buildroot))
try:
self.run_waf(["configure", "--board", px4_v,
"--out", self.buildroot, "clean"])
except subprocess.CalledProcessError:
self.progress("waf configure failed")
continue
try:
self.run_waf([
"build",
"--targets",
os.path.join("bin",
"".join([binaryname, framesuffix]))])
except subprocess.CalledProcessError:
msg = ("Failed build of %s %s%s %s for %s" %
(vehicle, board, framesuffix, tag, v))
self.progress(msg)
self.error_strings.append(msg)
continue

oldfile = os.path.join(self.buildroot, px4_v, "bin",
"%s%s.px4" % (binaryname, framesuffix))
newfile = "%s-%s.px4" % (px4_binaryname, v)
self.progress("Copying (%s) to (%s)" % (oldfile, newfile,))
try:
shutil.copyfile(oldfile, newfile)
except Exception as e:
self.progress("FIXME: narrow exception (%s)" % repr(e))
msg = ("Failed build copy of %s PX4%s %s for %s" %
(vehicle, framesuffix, tag, v))
self.progress(msg)
self.error_strings.append(msg)
continue
# FIXME: why the two stage copy?!
self.copyit(newfile, ddir, tag, vehicle)
self.checkout(vehicle, "latest")

def common_boards(self):
Expand Down Expand Up @@ -685,7 +633,6 @@ def build_arducopter(self, tag):
boards,
"Copter",
"arducopter",
"ArduCopter",
frames=[None, "heli"])

def build_arduplane(self, tag):
Expand All @@ -696,8 +643,7 @@ def build_arduplane(self, tag):
"ArduPlane",
boards,
"Plane",
"arduplane",
"ArduPlane")
"arduplane")

def build_antennatracker(self, tag):
'''build Tracker binaries'''
Expand All @@ -706,8 +652,7 @@ def build_antennatracker(self, tag):
"AntennaTracker",
boards,
"AntennaTracker",
"antennatracker",
"AntennaTracker",)
"antennatracker")

def build_rover(self, tag):
'''build Rover binaries'''
Expand All @@ -716,17 +661,15 @@ def build_rover(self, tag):
"Rover",
boards,
"Rover",
"ardurover",
"Rover")
"ardurover")

def build_ardusub(self, tag):
'''build Sub binaries'''
self.build_vehicle(tag,
"ArduSub",
self.common_boards(),
"Sub",
"ardusub",
"ArduSub")
"ardusub")

def build_AP_Periph(self, tag):
'''build AP_Periph binaries'''
Expand All @@ -735,7 +678,6 @@ def build_AP_Periph(self, tag):
"AP_Periph",
boards,
"AP_Periph",
"AP_Periph",
"AP_Periph")

def generate_manifest(self):
Expand Down
6 changes: 3 additions & 3 deletions Tools/scripts/configure-ci.sh
Expand Up @@ -6,8 +6,8 @@ set -ex
# Disable ccache for the configure phase, it's not worth it
export CCACHE_DISABLE="true"

ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update"
ARM_TARBALL="$ARM_ROOT-linux.tar.bz2"
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"

RPI_ROOT="master"
RPI_TARBALL="$RPI_ROOT.tar.gz"
Expand Down Expand Up @@ -83,7 +83,7 @@ ln -s ~/opt/$CCACHE_ROOT/ccache ~/ccache/clang
exportline="export PATH=$HOME/ccache"
exportline="${exportline}:$HOME/bin"
exportline="${exportline}:$HOME/.local/bin"
exportline="${exportline}:$HOME/opt/gcc-arm-none-eabi-6-2017-q2-update/bin"
exportline="${exportline}:$HOME/opt/gcc-arm-none-eabi-10-2020-q4-major/bin"
exportline="${exportline}:$HOME/opt/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"
exportline="${exportline}:$HOME/opt/arm-linux-musleabihf-cross/bin"
exportline="${exportline}:$HOME/opt/$CCACHE_ROOT"
Expand Down
4 changes: 3 additions & 1 deletion libraries/AP_Compass/Compass_learn.cpp
Expand Up @@ -164,7 +164,9 @@ void CompassLearn::update(void)
sample_available = false;
num_samples = 0;
have_earth_field = false;
memset(predicted_offsets, 0, sizeof(predicted_offsets));
tridge marked this conversation as resolved.
Show resolved Hide resolved
for (auto &v : predicted_offsets) {
v.zero();
}
worst_error = 0;
best_error = 0;
best_yaw_deg = 0;
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp
Expand Up @@ -376,7 +376,7 @@ void AP_InertialSensor::TCal::update_gyro_learning(const Vector3f &gyro, float t
*/
void AP_InertialSensor::TCal::Learn::reset(float temperature)
{
memset(state, 0, sizeof(state));
memset((void*)&state[0], 0, sizeof(state));
start_tmax = tcal.temp_max;
accel_start.zero();
for (uint8_t i=0; i<ARRAY_SIZE(state); i++) {
Expand Down
2 changes: 1 addition & 1 deletion modules/ChibiOS
Submodule ChibiOS updated 0 files
4 changes: 4 additions & 0 deletions wscript
Expand Up @@ -286,6 +286,10 @@ configuration in order to save typing.
default=None,
help='Extra hwdef.dat file for custom build.')

g.add_option('--assert-cc-version',
default=None,
help='fail configure if not using the specified gcc version')

def _collect_autoconfig_files(cfg):
for m in sys.modules.values():
paths = []
Expand Down