Skip to content

Commit

Permalink
i#3002: Build ARM, AArch64, and Android cronbuild packages (#4090)
Browse files Browse the repository at this point in the history
Adds jobs to the Travis cronbuild matrix to build ARM, AArch64, and
Android packages.  Adds toolchain setting based on the existing env
var and parameter scheme into package.cmake to match runsuite.cmake.
Adds logic to exclude the Dr. Memory build for AArch64.  Adds ignoring
of a "git tag" failure to handle races among the four jobs.

Adds the 32_only and 64_only args to package.cmake to match runsuite.cmake.
Fixes the Windows Dr. Memory checkout directory.
Makes a Dr. Memory embedded build location error fatal.

Adds proper naming of cross-compiled packages, including adding a new PACKAGE_SUBSYS CMake variable for setting -EABIHF, etc. suffixes.

Issue: #2861
Fixes #3002
  • Loading branch information
derekbruening authored Feb 10, 2020
1 parent 47ea6ac commit 3378573
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 18 deletions.
6 changes: 4 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ install:
# XXX i#2145: point at Qt5 for testing drgui build.

# Include Dr. Memory in cronbuild packages.
# We're in C:/projects/install now while we'll be in C:/projects/dynamorio to build.
# We do shallow clones and assume DrM will update its DR at least once
# every 250 DR commits.
- ps: >-
If ($env:APPVEYOR_REPO_TAG -Match "true") {
cd ..\dynamorio
git clone --depth=2 https://github.com/DynamoRIO/drmemory.git drmemory
cd drmemory
git submodule update --init --depth 250
cd ..
cd ..\..\install
}
before_build:
Expand Down Expand Up @@ -132,7 +134,7 @@ deploy:
force_update: true
# Using the default "release:" name (the tag) to match Travis.
# This description replaces the one provided by Travis.
description: 'Auto-generated periodic build (Appveyor build $(appveyor_build_version)). Unlike official release builds, Dr. Memory is not included in this build, and for Linux, i686 is separated from x86_64 rather than being combined in one package.'
description: 'Auto-generated periodic build.'
on:
branch: master
appveyor_repo_tag: true
29 changes: 26 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ language:
# with excludes so we can use conditional builds (plus it's clearer this way).
jobs:
include:
#######################################################################
# Regular test jobs:

# 32-bit Linux build with gcc and run tests:
- if: env(TRAVIS_EVENT_TYPE) != cron
os: linux
Expand Down Expand Up @@ -111,12 +114,29 @@ jobs:
compiler: clang
# We do not have 64-bit support on OSX yet (i#1979).
env: DYNAMORIO_CROSS_AARCHXX_LINUX_ONLY=no DEPLOY=no EXTRA_ARGS=32_only
# Package builds.

#######################################################################
# Package jobs
# Linux x86 + amd64:
- if: env(TRAVIS_EVENT_TYPE) = cron
os: linux
compiler: gcc
env: DYNAMORIO_CROSS_AARCHXX_LINUX_ONLY=no DEPLOY=yes
# TODO i#3002: Build packages for AArchXX.
# Linux AArch64:
- if: env(TRAVIS_EVENT_TYPE) = cron
os: linux
compiler: gcc
env: DYNAMORIO_CROSS_AARCHXX_LINUX_ONLY=yes DEPLOY=yes EXTRA_ARGS=64_only
# Linux ARM:
- if: env(TRAVIS_EVENT_TYPE) = cron
os: linux
compiler: gcc
env: DYNAMORIO_CROSS_AARCHXX_LINUX_ONLY=yes DEPLOY=yes EXTRA_ARGS=32_only
# Android ARM:
- if: env(TRAVIS_EVENT_TYPE) = cron
os: linux
compiler: gcc
env: DYNAMORIO_CROSS_ANDROID_ONLY=yes DYNAMORIO_ANDROID_TOOLCHAIN='/tmp/android-gcc-arm-ndk-10e' DEPLOY=no EXTRA_ARGS=32_only

# For C/C++ there is no default install, so we set "install", not "before_install".
install:
Expand Down Expand Up @@ -176,7 +196,10 @@ before_deploy:
# We support setting TAG_SUFFIX on triggered builds so we can have
# multiple unique tags in one day (the patchlevel here is the day number).
- export GIT_TAG="cronbuild-7.91.$((`git log -n 1 --format=%ct` / (60*60*24)))${TAG_SUFFIX}"
- git tag $GIT_TAG -a -m "Travis auto-generated tag for build $TRAVIS_BUILD_NUMBER."
# We handle races among our 4 package jobs by ignoring failure here.
# XXX: That could mask a real failure: we could try to distinguish the
# type of error.
- git tag $GIT_TAG -a -m "Travis auto-generated tag for build $TRAVIS_BUILD_NUMBER." || echo "Race to create tag: must already exist"
deploy:
provider: releases
api_key:
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,16 @@ set(BUILD_NUMBER "0" CACHE STRING "Build number (must be <64K)")
set(UNIQUE_BUILD_NUMBER "0" CACHE STRING "Unique build number")
set(CUSTOM_PRODUCT_NAME "" CACHE STRING "Custom product name")
set(PACKAGE_PLATFORM "" CACHE STRING "Platform for package name (should have trailing -)")
set(PACKAGE_SUBSYS "" CACHE STRING
"Platform for sub-system name (should have leading -: e.g., -EABIHF")
mark_as_advanced(
VERSION_NUMBER
VERSION_COMMA_DELIMITED
BUILD_NUMBER
UNIQUE_BUILD_NUMBER
CUSTOM_PRODUCT_NAME
PACKAGE_PLATFORM
PACKAGE_SUBSYS
)
# This is hardcoded in globals_shared.h: going to leave it that way, but
# adding indirection within cmake files
Expand Down Expand Up @@ -1956,7 +1959,7 @@ DR_target_install_dst(${INSTALL_CMAKE} EXPORT ${exported_targets_name})
# CPACK_INSTALL_CMAKE_PROJECTS variable is set to point at all 4 builds,
# "make package" will produce a package from all 4 installs.

# FIXME i#74: create source tarball via 'make package_source'
# TODO i#74: create source tarball via 'make package_source'
# Just need to exclude exports/ (or move exports/ to ../?) and
# other files inside source dir (or run on untouched source dir)
# and update package.{sh,bat}.
Expand All @@ -1973,11 +1976,12 @@ if (UNIX)
set(CPACK_STRIP_FILES OFF)
if (APPLE)
set(CPACK_SYSTEM_NAME "MacOS")
elseif (ANDROID)
set(CPACK_SYSTEM_NAME "Android")
else ()
set(CPACK_SYSTEM_NAME "Linux")
endif ()
else (UNIX)
# FIXME: try Windows NSIS
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_SYSTEM_NAME "Windows")
Expand All @@ -2004,7 +2008,7 @@ string(REGEX REPLACE
# having the full version in the base dir is a good thing, though I'm not
# sure about the caps.
set(CPACK_PACKAGE_FILE_NAME
"DynamoRIO-${PACKAGE_PLATFORM}${CPACK_SYSTEM_NAME}-${CPACK_PACKAGE_VERSION}-${BUILD_NUMBER}")
"DynamoRIO-${PACKAGE_PLATFORM}${CPACK_SYSTEM_NAME}${PACKAGE_SUBSYS}-${CPACK_PACKAGE_VERSION}-${BUILD_NUMBER}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "dynamorio")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "DynamoRIO")
set(CPACK_PACKAGE_RELOCATABLE "true")
Expand Down
50 changes: 45 additions & 5 deletions make/package.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2011-2017 Google, Inc. All rights reserved.
# Copyright (c) 2011-2020 Google, Inc. All rights reserved.
# Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
# **********************************************************

Expand Down Expand Up @@ -42,6 +42,7 @@
# ctest -V -S /my/path/to/dynamorio/src/make/package.cmake,build=1\;version=5.0.0\;invoke=/my/path/to/drmemory/src/package.cmake\;drmem_only\;cacheappend=TOOL_VERSION_NUMBER:STRING=1.6.0

cmake_minimum_required (VERSION 2.6)
set(CTEST_SOURCE_DIRECTORY "${CTEST_SCRIPT_DIRECTORY}/..")

# arguments are a ;-separated list (must escape as \; from ctest_run_script())
# required args:
Expand All @@ -58,6 +59,8 @@ set(arg_invoke "") # sub-project package.cmake to invoke
set(arg_preload "") # cmake file to include prior to each 32-bit build
set(arg_preload64 "") # cmake file to include prior to each 64-bit build
set(arg_cpackappend "")# string to append to CPackConfig.cmake before packaging
set(cross_aarchxx_linux_only OFF)
set(cross_android_only OFF)

foreach (arg ${CTEST_SCRIPT_ARG})
if (${arg} MATCHES "^build=")
Expand All @@ -77,10 +80,12 @@ foreach (arg ${CTEST_SCRIPT_ARG})
string(REGEX REPLACE "^cacheappend=" "" entry "${arg}")
set(arg_cacheappend "${arg_cacheappend}\n${entry}")
endif ()
if (${arg} MATCHES "^no64")
if (${arg} MATCHES "^no64" OR
${arg} MATCHES "^32_only")
set(arg_no64 ON)
endif ()
if (${arg} MATCHES "^no32")
if (${arg} MATCHES "^no32" OR
${arg} MATCHES "^64_only")
set(arg_no32 ON)
endif ()
if (${arg} MATCHES "^invoke=")
Expand All @@ -91,6 +96,38 @@ foreach (arg ${CTEST_SCRIPT_ARG})
endif ()
endforeach (arg)

# These are set by env var instead of arg to match Travis test jobs.
if ($ENV{DYNAMORIO_CROSS_AARCHXX_LINUX_ONLY} MATCHES "yes")
set(cross_aarchxx_linux_only ON)
set(ARCH_IS_X86 OFF)
if (arg_no32)
set(arg_cacheappend "${arg_cacheappend}
PACKAGE_PLATFORM:STRING=AArch64-
CMAKE_TOOLCHAIN_FILE:PATH=${CTEST_SOURCE_DIRECTORY}/make/toolchain-arm64.cmake")
elseif (arg_no64)
set(arg_cacheappend "${arg_cacheappend}
PACKAGE_PLATFORM:STRING=ARM-
PACKAGE_SUBSYS:STRING=-EABIHF
CMAKE_TOOLCHAIN_FILE:PATH=${CTEST_SOURCE_DIRECTORY}/make/toolchain-arm32.cmake")
else ()
message(FATAL_ERROR "package.cmake supports just one package at a time and 32-bit "
"and 64-bit AArch cannot be combined")
endif ()
endif()
if ($ENV{DYNAMORIO_CROSS_ANDROID_ONLY} MATCHES "yes")
set(cross_android_only ON)
set(ARCH_IS_X86 OFF)
if (arg_no64)
set(arg_cacheappend "${arg_cacheappend}
PACKAGE_PLATFORM:STRING=ARM-
PACKAGE_SUBSYS:STRING=-EABI
CMAKE_TOOLCHAIN_FILE:PATH=${CTEST_SOURCE_DIRECTORY}/make/toolchain-android.cmake
ANDROID_TOOLCHAIN:PATH=$ENV{DYNAMORIO_ANDROID_TOOLCHAIN}")
else ()
message(FATAL_ERROR "Android is only supported as 32_only")
endif ()
endif()

if ("${arg_build}" STREQUAL "")
message(FATAL_ERROR "build number not set: pass as build= arg")
endif()
Expand Down Expand Up @@ -119,10 +156,10 @@ if (NOT APPLE AND NOT arg_no32)
endif ()

set(base_cache "
${base_cache}
BUILD_NUMBER:STRING=${arg_build}
UNIQUE_BUILD_NUMBER:STRING=${arg_ubuild}
${arg_cacheappend}
${base_cache}
")

# version is optional
Expand Down Expand Up @@ -164,7 +201,10 @@ if (NOT arg_invoke STREQUAL "")
set(save_last_dir ${last_package_build_dir})
set(arg_sub_package ON)
set(arg_sub_script ${arg_invoke})
include("${arg_invoke}")
include("${arg_invoke}" RESULT_VARIABLE invoke_res)
if (NOT invoke_res)
message(FATAL_ERROR "Failed in invoke sub-project ${arg_invoke}")
endif ()
set(last_package_build_dir ${save_last_dir})
endif ()

Expand Down
10 changes: 6 additions & 4 deletions suite/runsuite_common_pre.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ endif (arg_ssh)

# Make it clear that single-bitwidth packages only contain that bitwidth
# (and provide unique names for Travis deployment).
if (arg_64_only)
set(base_cache "${base_cache}
if (NOT "${base_cache}" MATCHES "PACKAGE_PLATFORM")
if (arg_64_only)
set(base_cache "${base_cache}
PACKAGE_PLATFORM:STRING=x86_64-")
elseif (arg_32_only)
set(base_cache "${base_cache}
elseif (arg_32_only)
set(base_cache "${base_cache}
PACKAGE_PLATFORM:STRING=i386-")
endif ()
endif ()
if (arg_use_make)
find_program(MAKE_COMMAND make DOC "make command")
Expand Down
17 changes: 16 additions & 1 deletion suite/runsuite_wrapper.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
# a Travis matrix of builds.
# Travis only supports Linux and Mac, so we're ok relying on perl.

# XXX: We currently have a patchwork of scripts and methods of passing arguments
# (some are env vars while others are command-line parameters) and thus have
# too many control points for the details of test builds and package builds.
# Maybe we can clean it up and eliminate this layer of script by moving logic
# in both directions (.{travis,appveyor}.yml and {runsuite,package}.cmake)?

use strict;
use Config;
use Cwd 'abs_path';
Expand Down Expand Up @@ -83,8 +89,17 @@
} elsif ($ENV{'TRAVIS_EVENT_TYPE'} eq 'cron' ||
$ENV{'APPVEYOR_REPO_TAG'} eq 'true') {
# A package build.
my $def_args = "build=1;invoke=${osdir}/../drmemory/package.cmake;drmem_only";
$args =~ s/^,/;/;
# XXX: Should we get rid of the build #? It was useful for manual build
# release candidates but makes less sense for automated builds.
my $def_args = "build=1";
# Include Dr. Memory.
if (($is_aarchxx || $ENV{'DYNAMORIO_CROSS_AARCHXX_LINUX_ONLY'} eq 'yes') &&
$args =~ /64_only/) {
# Dr. Memory is not ported to AArch64 yet.
} else {
$def_args = "${def_args};invoke=${osdir}/../drmemory/package.cmake;drmem_only";
}
system("ctest -VV -S \"${osdir}/../make/package.cmake,${def_args}${args}\" 2>&1");
exit 0;
} else {
Expand Down

0 comments on commit 3378573

Please sign in to comment.