Skip to content

Asan Setup and Settings Map #558

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0a0861
add asan setup and change to settings map
thansen-amd Oct 12, 2023
67ddaf9
staticanalysis settings
thansen-amd Oct 12, 2023
19b6878
link test command with asan files
thansen-amd Oct 17, 2023
16930dd
test command to settings map
thansen-amd Oct 17, 2023
3712950
string literal for multiple commands
thansen-amd Oct 17, 2023
5b7bbb8
Asan Setup and Settings Map
amd-garydeng Sep 26, 2024
6969dbd
xnack toggle for ASAN CI
amd-garydeng Sep 30, 2024
055aab6
hard code gfx942:xnack+ for testing
amd-garydeng Sep 30, 2024
a0ef31f
set amdclang++ and debug ldd info
amd-garydeng Oct 7, 2024
6e03d24
use install script
amd-garydeng Oct 7, 2024
65b6baf
removed cd
amd-garydeng Oct 7, 2024
83308e2
CD fix
amd-garydeng Oct 7, 2024
09151b2
give permisions to install
amd-garydeng Oct 7, 2024
8f56257
env variables
amd-garydeng Oct 7, 2024
bdc8189
env variables
amd-garydeng Oct 7, 2024
e43e373
fix syntax
amd-garydeng Oct 7, 2024
5d83354
fix exports
amd-garydeng Oct 7, 2024
b475dea
use cmake
amd-garydeng Oct 7, 2024
7565aaa
remove env variables
amd-garydeng Oct 7, 2024
d4d6724
add build dir
amd-garydeng Oct 7, 2024
e172d14
moved export var
amd-garydeng Oct 7, 2024
a6b284d
fixed export
amd-garydeng Oct 7, 2024
24fc221
fix exports
amd-garydeng Oct 7, 2024
fcbd342
ASAN env var
amd-garydeng Oct 8, 2024
0f17adc
fixed asan.groovy
amd-garydeng Oct 8, 2024
20a6867
fixed syntax
amd-garydeng Oct 8, 2024
0f0e6e7
Merge branch 'develop' into garydeng/asan
amd-garydeng Mar 4, 2025
65b5327
fix merge conflict
amd-garydeng May 29, 2025
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
80 changes: 80 additions & 0 deletions .jenkins/asan.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env groovy
@Library('rocJenkins@pong') _
import com.amd.project.*
import com.amd.docker.*
import java.nio.file.Path;

def runCI =
{
nodeDetails, jobName->

def prj = new rocProject('rocRAND', 'address-sanitizer')

def nodes = new dockerNodes(nodeDetails, jobName, prj)

def commonGroovy

def settings = [addressSanitizer: true]

boolean formatCheck = false

def compileCommand =
{
platform, project->

commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy"
commonGroovy.runCompileCommand(platform, project, jobName, settings)
}


def testCommand =
{
platform, project->

commonGroovy.runTestCommand(platform, project, settings)
}

def packageCommand =
{
platform, project->

commonGroovy.runPackageCommand(platform, project)
}

buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand)
}

ci: {
String urlJobName = auxiliary.getTopJobName(env.BUILD_URL)

def propertyList = ["compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 0')])]]
propertyList = auxiliary.appendPropertyList(propertyList)

def jobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu18:['gfx900'],centos7:['gfx906'],centos8:['gfx906'],sles15sp1:['gfx908']])]
jobNameList = auxiliary.appendJobNameList(jobNameList)

propertyList.each
{
jobName, property->
if (urlJobName == jobName)
properties(auxiliary.addCommonProperties(property))
}

jobNameList.each
{
jobName, nodeDetails->
if (urlJobName == jobName)
stage(jobName) {
runCI(nodeDetails, jobName)
}
}

// For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901
if(!jobNameList.keySet().contains(urlJobName))
{
properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])]))
stage(urlJobName) {
runCI([ubuntu16:['gfx906']], urlJobName)
}
}
}
36 changes: 27 additions & 9 deletions .jenkins/common.groovy
Original file line number Diff line number Diff line change
@@ -1,51 +1,69 @@
// This file is for internal AMD use.
// If you are interested in running your own Jenkins, please raise a github issue for assistance.

def runCompileCommand(platform, project, jobName, boolean debug=false, boolean staticLibrary=false, boolean codeCoverage=false)
def runCompileCommand(platform, project, jobName, settings)
{
project.paths.construct_build_prefix()

project.paths.build_command = './install -c'
String buildTypeArg = debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release'
String buildTypeDir = debug ? 'debug' : 'release'
String buildStatic = staticLibrary ? '-DBUILD_SHARED_LIBS=OFF' : '-DBUILD_SHARED_LIBS=ON'
String codeCovFlag = codeCoverage ? '-DCODE_COVERAGE=ON' : ''
String buildTypeArg = settings.debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release'
String buildTypeDir = settings.debug ? 'debug' : 'release'
String buildStatic = settings.staticLibrary ? '-DBUILD_STATIC_LIBS=ON' : '-DBUILD_SHARED=OFF'
String codeCovFlag = settings.codeCoverage ? '-DCODE_COVERAGE=ON' : ''
String asanFlag = settings.addressSanitizer ? '-DBUILD_ADDRESS_SANITIZER=ON' : ''
String cmake = platform.jenkinsLabel.contains('centos') ? 'cmake3' : 'cmake'
String cmakePrefixPath = '-DCMAKE_PREFIX_PATH="/opt/rocm;/opt/rocm/llvm;/opt/rocm/bin"'
//Set CI node's gfx arch as target if PR, otherwise use default targets of the library
String amdgpuTargets = env.BRANCH_NAME.startsWith('PR-') ? '-DAMDGPU_TARGETS=\$gfx_arch' : ''

String xnackToggle = settings.addressSanitizer ? "export HSA_XNACK=1" : ''

def command = """#!/usr/bin/env bash
set -x
${xnackToggle}
cd ${project.paths.project_build_prefix}
mkdir -p build/${buildTypeDir} && cd build/${buildTypeDir}
# gfxTargetParser reads gfxarch and adds target features such as xnack
${auxiliary.gfxTargetParser()}
${cmake} --toolchain=toolchain-linux.cmake ${cmakePrefixPath} ${buildTypeArg} ${buildStatic} ${amdgpuTargets} ${codeCovFlag} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../..
${cmake} --toolchain=toolchain-linux.cmake ${cmakePrefixPath} ${buildTypeArg} ${buildStatic} ${amdgpuTargets} ${codeCovFlag} ${asanFlag} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../..
make -j\$(nproc)
"""

platform.runCommand(this, command)
}

def runTestCommand (platform, project, boolean rocmExamples=false)
def runTestCommand (platform, project, settings)
{
String sudo = auxiliary.sudo(platform.jenkinsLabel)
// String centos = platform.jenkinsLabel.contains('centos') ? '3' : ''
// Disable xorwow test for now as it is a known failure with gfx90a.
// def testCommand = "ctest${centos} --output-on-failure"
def testCommand = "ctest --output-on-failure"

String LD_PATH = settings.addressSanitizer ? """export ASAN_LIB_PATH=\$(/opt/rocm/llvm/bin/clang -print-file-name=libclang_rt.asan-x86_64.so)
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$(dirname "\${ASAN_LIB_PATH}")""" : 'export LD_LIBRARY_PATH=/opt/rocm/lib/'

String ASAN_EXPORTS = settings.addressSanitizer ? """export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/rocm/llvm/lib/clang/18/lib/linux
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/rocm/lib/asan
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/rocm/libexec/rocm_smi
export ASAN_SYMBOLIZER_PATH=/opt/rocm/llvm/bin/llvm-symbolizer
export PATH=/opt/rocm/llvm/bin/:\$PATH
export PATH=/opt/rocm/:\$PATH
export HSA_XNACK=1
export ASAN_OPTIONS=detect_leaks=0""" : ''

def command = """#!/usr/bin/env bash
set -x
cd ${project.paths.project_build_prefix}/build/release
make -j4
${sudo} LD_LIBRARY_PATH=/opt/rocm/lib/ ${testCommand}
${LD_PATH}
${ASAN_EXPORTS}
${sudo} ${testCommand}
"""

platform.runCommand(this, command)
//ROCM Examples
if (rocmExamples){
if (settings.rocmExamples){
String buildString = ""
if (platform.os.contains("ubuntu")){
buildString += "sudo dpkg -i *.deb"
Expand Down
7 changes: 5 additions & 2 deletions .jenkins/precheckin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ def runCI =

def commonGroovy

def settings = [rocmExamples: true]


boolean formatCheck = false

def compileCommand =
{
platform, project->

commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy"
commonGroovy.runCompileCommand(platform, project, jobName)
commonGroovy.runCompileCommand(platform, project, jobName, settings)
}


def testCommand =
{
platform, project->

commonGroovy.runTestCommand(platform, project, true)
commonGroovy.runTestCommand(platform, project, settings)
}

def packageCommand =
Expand Down
6 changes: 4 additions & 2 deletions .jenkins/static.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ def runCI =

def commonGroovy

def settings = [staticLibrary: true]

boolean formatCheck = false

def compileCommand =
{
platform, project->

commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy"
commonGroovy.runCompileCommand(platform, project, jobName, debug=false, staticLibrary=true)
commonGroovy.runCompileCommand(platform, project, jobName, settings)
}

def testCommand =
{
platform, project->

commonGroovy.runTestCommand(platform, project)
commonGroovy.runTestCommand(platform, project, settings)
}

def packageCommand =
Expand Down
6 changes: 4 additions & 2 deletions .jenkins/staticanalysis.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import com.amd.project.*
import com.amd.docker.*
import java.nio.file.Path

def runCompileCommand(platform, project, jobName, boolean debug=false)
def runCompileCommand(platform, project, jobName, settings)
{
project.paths.construct_build_prefix()
}

def runCI =
{
def settings = [:]

nodeDetails, jobName->

def prj = new rocProject('rocRAND', 'StaticAnalysis')
Expand All @@ -30,7 +32,7 @@ def runCI =
{
platform, project->

runCompileCommand(platform, project, jobName, false)
runCompileCommand(platform, project, jobName, settings)
}

buildProject(prj , formatCheck, nodes.dockerArray, compileCommand, null, null, staticAnalysis)
Expand Down