@@ -385,6 +385,15 @@ cmd_help() {
385
385
echo " -l, --libc musl|gnu Choose the libc flavor against which Firecracker will"
386
386
echo " be linked. Default is musl."
387
387
echo " "
388
+ echo " strip [--target-libc musl|gnu]"
389
+ echo " Strip from debug symbols the Firecracker binaries."
390
+ echo " "
391
+ echo " --target-libc musl|gnu Choose the target libc flavor which determines the"
392
+ echo " toolchain used to build Firecracker release binaries."
393
+ echo " Stripping will occur only for the Firecracker release"
394
+ echo " binaries corresponding to the inferred toolchain. Default"
395
+ echo " is musl."
396
+ echo " "
388
397
echo " fmt"
389
398
echo " Auto-format all Rust source files, to match the Firecracker requirements."
390
399
echo " This should be used as the last step in every commit, to ensure that the"
@@ -500,6 +509,54 @@ cmd_build() {
500
509
return $ret
501
510
}
502
511
512
+ cmd_strip () {
513
+ profile=" release"
514
+ libc=" musl"
515
+ target=" $( uname -m) -unknown-linux-${libc} "
516
+
517
+ # Parse any command line args.
518
+ while [ $# -gt 0 ]; do
519
+ case " $1 " in
520
+ " -h" |" --help" ) { cmd_help; exit 1; } ;;
521
+ " --target-libc" )
522
+ shift
523
+ [[ " $1 " =~ ^(musl| gnu)$ ]] || \
524
+ die " Invalid libc: $1 . Valid options are \" musl\" and \" gnu\" ."
525
+ libc=" $1 "
526
+ target=" $( uname -m) -unknown-linux-${libc} "
527
+ ;;
528
+ * )
529
+ die " Unknown argument: $1 . Please use --help for help."
530
+ ;;
531
+ esac
532
+ shift
533
+ done
534
+
535
+ # Check prerequisites
536
+ ensure_devctr
537
+ ensure_build_dir
538
+
539
+ say " Starting stripping the debug symbols for $profile binaries built against $target target."
540
+ strip_flags=" --strip-debug"
541
+ say " Strip flags: $strip_flags ."
542
+
543
+ run_devctr \
544
+ --user " $( id -u) :$( id -g) " \
545
+ -- \
546
+ strip $strip_flags \
547
+ " $CTR_CARGO_TARGET_DIR /$target /$profile /firecracker" \
548
+ " $CTR_CARGO_TARGET_DIR /$target /$profile /jailer"
549
+ ret=$?
550
+
551
+ [ $ret -eq 0 ] && {
552
+ cargo_bin_dir=" $CARGO_TARGET_DIR /$target /$profile "
553
+ say " Stripping was successful."
554
+ say " Stripped binaries placed under $cargo_bin_dir ."
555
+ }
556
+
557
+ return $?
558
+ }
559
+
503
560
# `$0 test` - run integration tests
504
561
# Please see `$0 help` for more information.
505
562
#
0 commit comments