Skip to content

Commit

Permalink
Ignorelist for asan
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed May 30, 2022
1 parent 0406bc7 commit 30080d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ lazy val bindgen = project
.dependsOn(libclang)
.enablePlugins(ScalaNativePlugin, ScalaNativeJUnitPlugin)
.settings(nativeCommon)
.settings(Compile / nativeConfig ~= environmentConfiguration)
.settings(Compile / nativeConfig := {
val config = (Compile / nativeConfig).value
val base = (ThisBuild / baseDirectory).value
environmentConfiguration(config, base)
})
.settings(nativeConfig ~= usesLibClang)
.settings(Test / nativeConfig ~= usesLibClang)
.settings(clangDetection)
Expand Down Expand Up @@ -395,16 +399,20 @@ def generateExampleBindings(
builder.generate(defined, destination, lang, ci)
}

def environmentConfiguration(conf: NativeConfig): NativeConfig = {
def environmentConfiguration(conf: NativeConfig, base: File): NativeConfig = {
var modified = conf
if (sys.env.contains("SN_RELEASE"))
modified = modified.withMode(Mode.releaseFast)

if (sys.env.contains("SN_SANITIZE")) {
val opts =
"-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-return=always -fno-optimize-sibling-calls"
.split(' ')
.toList
List(
"-fsanitize=address",
"-fno-omit-frame-pointer",
"-fsanitize-address-use-after-return=always",
"-fno-optimize-sibling-calls",
s"-fsanitize-ignorelist=${base}/ignorelist.txt"
)

modified = modified
.withLinkingOptions(modified.linkingOptions ++ opts)
Expand Down
1 change: 1 addition & 0 deletions ignorelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fun:*scalanative.runtime.MemoryPool*

0 comments on commit 30080d3

Please sign in to comment.