Backport ab017fbb and b3b952d6

ab017fbb: bootstrap/gcc.bst: Fix confusion of binaries used for target and build.

When not cross-compiling, the tools have the same names, and only
the first one in PATH is used. Intermediate binaries intended
to run during the build might get linked to the target system
rather than the current system.

b3b952d6: Fix and cleanup environment variables in elements for GCC.

There were a lot of confusions on what variables should be used to
compile GCC. This ended up with "host" tools not being compiled with
the proper flags. See #784.

"Build" is for tools built as intermediate that needs to run during
the build.  For example source code generators. Environment variables
for those are suffixed with `_FOR_BUILD`. For example `CC_FOR_BUILD`,
`CLFAGS_FOR_BUILD`.

"Host" is for the compiler itself as well as all its development
tools. Default environment variables are used for those, e.g. `CC`,
`CFLAGS`.

"Target" are the runtime and libraries that needs to be linked to the
result of compilation with the new built compiler. This is for example
`libgcc`, `libstdc++`, and runtime objects (`crt*.o`). Environment
variables for those are suffixed with `_FOR_TARGET`. For example
`CC_FOR_TARGET`, `CLFAGS_FOR_TARGET`.

When building a cross-compiler, `build == host`. We need to set `CC`,
`CXX`, `CFLAGS`, `CXXFLAGS`, `LDFLAGS`, etc. for the build/host
architecture.  Then we set `CC_FOR_TARGET`, `CFLAGS_FOR_TARGET`,
etc. for the target architecture.

When cross-compiling the final compiler, `host == target`. In that
case, `CC`, `CFLAGS`, etc. ar set to the host/target architecture. We
then need to set `CC_FOR_BUILD`, `CFLAGS_FOR_BUILD`, etc. for the
build architecture.

When we do not cross-compile, that is `build == host && host ==
target`, we should still use the right compiler otherwise we end-up
link to the wrong library. By default GCC's configure ignore
`*_FOR_BUILD` tool variables in this case. We patch it to not ignore
it, because build and host really need to use different compilers.

For `libstc++-stage1.bst`, is a subdirectory of gcc. It is a intended
for the "target", the default flags should be the one for the target.
It does not have any "build" tool so it does not need `*_FOR_BUILD`
variables.
8 jobs for valentindavid/gcc-flags-1808 in 332 minutes and 41 seconds (queued for 2 seconds)
Status Job ID Name Coverage
  Flatpak
failed #235026398
aarch64
app_aarch64

00:16:58

failed #235026399
armhf
app_arm

05:15:41

failed #235026397
cache_i686 x86_64
app_i686

00:15:29

failed #235026396
cache_x86_64 x86_64
app_x86_64

00:14:18

 
  Vm
skipped #235026402
aarch64 allowed to fail manual
minimal_systemd_vm_aarch64
skipped #235026404
armhf
minimal_systemd_vm_arm
skipped #235026401
cache_i686 x86_64
minimal_systemd_vm_i686
skipped #235026400
cache_x86_64 x86_64
minimal_systemd_vm_x86_64
 
Name Stage Failure
failed
app_arm Flatpak
  File "./utils/check-abi", line 129, in bst
subprocess.check_call(cmd, encoding='utf-8')
File "/usr/lib64/python3.7/subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bst', '--colors', 'build', 'abi/desktop-abi-image.bst']' returned non-zero exit status 255.
Uploading artifacts...
/builds/freedesktop-sdk/freedesktop-sdk/cache/buildstream/logs: found 2336 matching files
Uploading artifacts to coordinator... ok id=235026399 responseStatus=201 Created token=EsMTbPDY
ERROR: Job failed: exit code 1
failed
app_aarch64 Flatpak
  Build Queue: processed 0,   skipped 18,  failed 1 
Push Queue: processed 0, skipped 18, failed 0


make: *** [Makefile:35: build] Error 255
Uploading artifacts...
/builds/freedesktop-sdk/freedesktop-sdk/cache/buildstream/logs: found 1130 matching files
Uploading artifacts to coordinator... ok id=235026398 responseStatus=201 Created token=EXbqxdyg
ERROR: Job failed: exit code 1
failed
app_i686 Flatpak
  Build Queue: processed 0,   skipped 17,  failed 1 
Push Queue: processed 0, skipped 17, failed 0


make: *** [Makefile:35: build] Error 255
Uploading artifacts...
/builds/freedesktop-sdk/freedesktop-sdk/cache/buildstream/logs: found 1134 matching files
Uploading artifacts to coordinator... ok id=235026397 responseStatus=201 Created token=dzqS_AHb
ERROR: Job failed: exit code 1
failed
app_x86_64 Flatpak
  Build Queue: processed 0,   skipped 17,  failed 1 
Push Queue: processed 0, skipped 17, failed 0


make: *** [Makefile:35: build] Error 255
Uploading artifacts...
/builds/freedesktop-sdk/freedesktop-sdk/cache/buildstream/logs: found 1133 matching files
Uploading artifacts to coordinator... ok id=235026396 responseStatus=201 Created token=DG74L3Vq
ERROR: Job failed: exit code 1