Skip to content

Commit

Permalink
Merge pull request #16492 from pshipton/winupd
Browse files Browse the repository at this point in the history
(0.36) Update OpenJ9 build for Windows
  • Loading branch information
AdamBrousseau committed Dec 20, 2022
2 parents 5a2c90b + 15b3b18 commit c5da55c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
70 changes: 64 additions & 6 deletions buildenv/jenkins/common/build.groovy
Expand Up @@ -21,6 +21,9 @@
*******************************************************************************/
import groovy.json.JsonSlurper;
import groovy.json.JsonOutput;
import java.util.regex.Matcher
import java.util.regex.Pattern

pipelineFunctions = load 'buildenv/jenkins/common/pipeline-functions.groovy'

def get_source() {
Expand Down Expand Up @@ -284,17 +287,23 @@ def checkoutRef (REF) {

def build() {
stage('Compile') {
def make_target = 'all'
def freemarker_option = FREEMARKER ? "--with-freemarker-jar=${FREEMARKER}" : ""
OPENJDK_CLONE_DIR = "${env.WORKSPACE}/${OPENJDK_CLONE_DIR}"

withEnv(BUILD_ENV_VARS_LIST) {
dir(OPENJDK_CLONE_DIR) {
try {
def freemarker_option = FREEMARKER ? "--with-freemarker-jar=${FREEMARKER}" : ""
sh "${BUILD_ENV_CMD} bash configure ${freemarker_option} --with-boot-jdk=${BOOT_JDK} ${EXTRA_CONFIGURE_OPTIONS} && make ${EXTRA_MAKE_OPTIONS} ${make_target}"
} catch (e) {
archive_diagnostics()
throw e
sh "${BUILD_ENV_CMD} bash configure ${freemarker_option} --with-boot-jdk=${BOOT_JDK} ${EXTRA_CONFIGURE_OPTIONS} && ${get_compile_command()}"
} catch (Exception e) {
// last 5000 console output lines
LOG_MAX_LINES = params.LOG_MAX_LINES ? params.LOG_MAX_LINES.toInteger() : 5000
LOG_LINES = currentBuild.getRawBuild().getLog(LOG_MAX_LINES)
if (match_fail_pattern(LOG_LINES)) {
recompile()
} else {
archive_diagnostics()
throw e
}
}
}
}
Expand All @@ -306,6 +315,10 @@ def build() {
}
}

def get_compile_command() {
return "make ${EXTRA_MAKE_OPTIONS} all"
}

def archive_sdk() {
stage('Archive') {
def buildDir = "build/${RELEASE}/images/"
Expand Down Expand Up @@ -720,4 +733,49 @@ def build_all() {
}
}

def match_fail_pattern(outputLines) {
if (!FAIL_PATTERN) {
return false
}

println("Build failure, searching fail pattern in the last ${outputLines.size()} output lines")
Pattern pattern = Pattern.compile(FAIL_PATTERN)
for (line in outputLines) {
Matcher matcher = pattern.matcher(line)
if (matcher.find()) {
return true
}
}

println("Fail pattern not found!")
return false
}

def recompile() {
def maxRetry = 3
def retryCounter = 0
def doRetry = true

while ((maxRetry > retryCounter) && doRetry) {
retryCounter++
println("Attempt to recompile, retry: ${retryCounter}")

try {
sh "make clean && ${get_compile_command()}"
doRetry = false
} catch (Exception f) {
// crop console output, search only new output
def newLines = currentBuild.getRawBuild().getLog(LOG_MAX_LINES).minus(LOG_LINES)
// cache log
LOG_LINES.addAll(newLines)

if (!match_fail_pattern(newLines)) {
//different error
archive_diagnostics()
throw f
}
}
}
}

return this
4 changes: 3 additions & 1 deletion buildenv/jenkins/common/variables-functions.groovy
Expand Up @@ -1125,7 +1125,7 @@ def validate_arguments(ARGS) {
def printStackTrace(e) {
def writer = new StringWriter()
e.printStackTrace(new PrintWriter(writer))
echo e.toString()
echo writer.toString()
}

/*
Expand Down Expand Up @@ -1585,6 +1585,8 @@ def set_build_variables_per_node() {
}
}
}

FAIL_PATTERN = params.FAIL_PATTERN ?: buildspec.getScalarField('fail_pattern', SDK_VERSION)
}

def check_path(inPath) {
Expand Down
1 change: 1 addition & 0 deletions buildenv/jenkins/jobs/pipelines/Pipeline_Template.groovy
Expand Up @@ -121,6 +121,7 @@ pipelineJob("$JOB_NAME") {
} else if (jobType == 'build') {
stringParam('NODE')
choiceParam('JOB_TYPE', ['build'])
stringParam('FAIL_PATTERN')
}
}
}
6 changes: 2 additions & 4 deletions buildenv/jenkins/variables/defaults.yml
Expand Up @@ -344,8 +344,6 @@ aarch64_linux:
x86-64_windows:
extends: ['boot_jdk_default', 'cuda', 'debuginfo', 'openjdk_reference_repo', 'openssl', 'openssl_bundle']
boot_jdk:
location:
all: '/cygdrive/f/Users/jenkins/bootjdks'
arch: 'x64'
os: 'windows'
release:
Expand All @@ -365,14 +363,13 @@ x86-64_windows:
build: 'ci.role.build && hw.arch.x86 && sw.os.windows'
build_env:
vars: 'PATH+TOOLS=/cygdrive/c/openjdk/LLVM64/bin:/cygdrive/c/openjdk/nasm-2.13.03'
fail_pattern: 'C1083'
#========================================#
# Windows x86 32bits
#========================================#
x86-32_windows:
extends: ['boot_jdk_default', 'debuginfo', 'openjdk_reference_repo', 'openssl', 'openssl_bundle']
boot_jdk:
location:
all: '/cygdrive/f/Users/jenkins/bootjdks'
arch: 'x64'
os: 'windows'
release:
Expand All @@ -386,6 +383,7 @@ x86-32_windows:
build_env:
vars:
8: 'PATH+TOOLS=/cygdrive/c/openjdk/LLVM32/bin:/cygdrive/c/openjdk/nasm-2.13.03'
fail_pattern: 'C1083'
#========================================#
# Mac x86 64bits
#========================================#
Expand Down

0 comments on commit c5da55c

Please sign in to comment.