Repository: pytorch
Issue: Cannot build pytorch with linker arguments in C{,XX}FLAGS
Labels: module: build,triaged

## 🐛 Bug

When building pytorch with the following flags, the compiler aborts due to unknown arguments. To be specific, arguments of the for `-Wl,--sort-common` or `-Wl,-z,relro` get transformed to `-Wl --sort-common` or `-Wl -z relro` respectively. Apparently the commas are not respected by the build system and the different parts of the argument are separated.

Used flags:
```
 * CFLAGS='-march=native -O3 -pipe -fuse-linker-plugin -fgraphite-identity -floop-nest-optimize -fno-math-errno -fno-trapping-math -fassociative-math -fno-trapping-math -fno-signed-zeros -freciprocal-math -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=8 -Wl,-O1 -Wl,--as-needed -Wl,--sort-common,-z,now'
 * CXXFLAGS='-march=native -O3 -pipe -fuse-linker-plugin -fgraphite-identity -floop-nest-optimize -fno-math-errno -fno-trapping-math -fassociative-math -fno-trapping-math -fno-signed-zeros -freciprocal-math -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=8 -fvisibility-inlines-hidden -Wl,-O1 -Wl,--as-needed -Wl,--sort-common,-z,now'
 * FFLAGS='-march=native -O3 -pipe -fuse-linker-plugin -fgraphite-identity -floop-nest-optimize -fno-math-errno -fno-trapping-math -fassociative-math -fno-trapping-math -fno-signed-zeros -freciprocal-math -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=8 -Wl,-O1 -Wl,--as-needed -Wl,--sort-common,-z,now'
 * FCFLAGS='-march=native -O3 -pipe -fuse-linker-plugin -fgraphite-identity -floop-nest-optimize -fno-math-errno -fno-trapping-math -fassociative-math -fno-trapping-math -fno-signed-zeros -freciprocal-math -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=8 -Wl,-O1 -Wl,--as-needed -Wl,--sort-common,-z,now'
 * F77FLAGS='-march=native -O3 -pipe -fuse-linker-plugin -fgraphite-identity -floop-nest-optimize -fno-math-errno -fno-trapping-math -fassociative-math -fno-trapping-math -fno-signed-zeros -freciprocal-math -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=8 -Wl,-O1 -Wl,--as-needed -Wl,--sort-common,-z,now'
 * LDFLAGS='-Wl,-O1 -Wl,--as-needed -Wl,--sort-common,-z,now -march=native -O3 -pipe -fuse-linker-plugin -fgraphite-identity -floop-nest-optimize -fno-math-errno -fno-trapping-math -fassociative-math -fno-signed-zeros -freciprocal-math -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=8 -fvisibility-inlines-hidden'
 * MAKEOPTS='-j9 -l8.4'
```

(I tried to install pytorch from the official gentoo science overlay)

## To Reproduce

Install the the pytorch package on Gentoo from the science overlay. Alternatively, it should be reproducible by simply configuring and building the project with the given `C{,XX}FLAGS`.

I've attached the console output from the build here: [build.log](https://github.com/pytorch/pytorch/files/4553238/build.log)

## Expected behavior

Successful compilation.

## Environment

 - PyTorch Version (e.g., 1.0): 1.4
 - OS (e.g., Linux): Gentoo Linux
 - Compilers: gcc 9.3.0 and gcc 8.3.0
 - How you installed PyTorch (`conda`, `pip`, source): emerge sci-libs/pytorch (from https://github.com/gentoo/sci/tree/master/sci-libs/pytorch)
 - Build command you used (if compiling from source):
 - Python version: 3.6.10
 - CUDA/cuDNN version: 7.6.5 (CUDA 10.1)
 - GPU models and configuration: GT 730 / RX 580
 - Any other relevant information:


cc @malfet