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

Update OpenJ9 build for Windows #16334

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 64 additions & 6 deletions buildenv/jenkins/common/build.groovy
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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