@@ -14,23 +14,34 @@ const SECCOMPILER_SRC_DIR: &str = "../seccompiler/src";
1414fn main ( ) {
1515 // Target triple
1616 let target = std:: env:: var ( "TARGET" ) . expect ( "Missing target." ) ;
17+ let debug: bool = std:: env:: var ( "DEBUG" )
18+ . expect ( "Missing debug." )
19+ . parse ( )
20+ . expect ( "Invalid env variable DEBUG" ) ;
1721 let out_dir = std:: env:: var ( "OUT_DIR" ) . expect ( "Missing build-level OUT_DIR." ) ;
1822 // Target arch (x86_64 / aarch64)
1923 let target_arch = std:: env:: var ( "CARGO_CFG_TARGET_ARCH" ) . expect ( "Missing target arch." ) ;
2024
2125 let seccomp_json_path = format ! ( "{}/{}.json" , JSON_DIR , target) ;
22- // If the current target doesn't have a default filter, use a default, empty filter.
26+ // If the current target doesn't have a default filter, or if we're building a debug binary,
27+ // use a default, empty filter.
2328 // This is to make sure that Firecracker builds even with libc toolchains for which we don't
2429 // provide a default filter. For example, GNU libc.
25- let seccomp_json_path = if Path :: new ( & seccomp_json_path) . exists ( ) {
26- seccomp_json_path
27- } else {
30+ let seccomp_json_path = if debug {
31+ println ! (
32+ "cargo:warning=Using empty default seccomp policy for debug builds: \
33+ `resources/seccomp/unimplemented.json`."
34+ ) ;
35+ format ! ( "{}/unimplemented.json" , JSON_DIR )
36+ } else if !Path :: new ( & seccomp_json_path) . exists ( ) {
2837 println ! (
2938 "cargo:warning=No default seccomp policy for target: {}. Defaulting to \
3039 `resources/seccomp/unimplemented.json`.",
3140 target
3241 ) ;
3342 format ! ( "{}/unimplemented.json" , JSON_DIR )
43+ } else {
44+ seccomp_json_path
3445 } ;
3546
3647 // Retrigger the build script if the JSON file has changed.
0 commit comments