diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c index d5cf17dcd31..951f1fd6941 100644 --- a/src/cmd/dist/build.c +++ b/src/cmd/dist/build.c @@ -336,8 +336,7 @@ setup(void) */ // gccargs is the gcc command line to use for compiling a single C file. -static char *gccargs[] = { - "gcc", +static char *proto_gccargs[] = { "-Wall", "-Wno-sign-compare", "-Wno-missing-braces", @@ -352,6 +351,8 @@ static char *gccargs[] = { "-c", }; +static Vec gccargs; + // deptab lists changes to the default dependencies for a given prefix. // deps ending in /* read the whole directory; deps beginning with - // exclude files with that prefix. @@ -513,6 +514,16 @@ install(char *dir) vinit(&lib); vinit(&extra); + // set up gcc command line on first run. + if(gccargs.len == 0) { + xgetenv(&b, "CC"); + if(b.len == 0) + bprintf(&b, "gcc"); + splitfields(&gccargs, bstr(&b)); + for(i=0; i