#!/bin/sh # autopkgtest check: Build and run a program with the help of musl-gcc # (C) 2013 Thomas Moulard # (C) 2014 Anton Gladky # Author: Thomas Moulard # Anton Gladky set -e WORKDIR=$(mktemp -d) trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM cd $WORKDIR cat < hello.c #include int main(int argc, char **argv) { printf("hello %d\n", argc); return 0; } EOF musl-gcc -static -Os -o hello hello.c echo "build (static): OK" [ -x hello ] file hello | grep "statically linked" ./hello echo "run (static): OK" rm hello musl-gcc -fPIE -static-pie -Os -o hello hello.c echo "build (static-pie): OK" [ -x hello ] file hello | grep "static-pie linked" ./hello echo "run (static-pie): OK" rm hello musl-gcc -Os -o hello hello.c echo "build (dynamic): OK" [ -x hello ] file hello | grep "dynamically linked" ./hello echo "run (dynamic): OK" # test building with imported musl-fts cat < fts.c #include #include #include #include int main(int argc, char **argv) { char *path_argv[] = {"/", NULL}; FTS *fts = fts_open(path_argv, 0, NULL); fts_close(fts); return 0; } EOF musl-gcc -Os -o fts fts.c echo "build (fts): OK" [ -x fts ] ./fts echo "run (fts): OK"