From 14cca9e94ea0105af03ad2bfab7b9f3858cffdbd Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 24 Jun 2013 17:09:24 +0200 Subject: Workaround for Clang generating wrong debug info Clang obviously takes PWD as a basis for source paths in debug information (AT_comp_dir) if it is set. Since the build tools are not executed in a shell that would set PWD to a sensible value, debug information with Clang is broken if the build environment got a wrong PWD to start with, for example by starting Qt Creator from a shell (which sets PWD). Workaround is to explicitly unset PWD for the build environment used for the Clang tool chain. Task-number: QTCREATORBUG-8825 Change-Id: Ia3e47693121edd61b0ea43bddbb1fcaaac9eb390 Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/gcctoolchain.cpp | 10 ++++++++++ src/plugins/projectexplorer/gcctoolchain.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 31f4a47fe1..b06c91cd7a 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -1059,6 +1059,16 @@ QList ClangToolChain::suggestedMkspecList() const return QList(); // Note: Not supported by Qt yet, so default to the mkspec the Qt was build with } +void ClangToolChain::addToEnvironment(Environment &env) const +{ + GccToolChain::addToEnvironment(env); + // Clang takes PWD as basis for debug info, if set. + // When running Qt Creator from a shell, PWD is initially set to an "arbitrary" value. + // Since the tools are not called through a shell, PWD is never changed to the actual cwd, + // so we better make sure PWD is empty to begin with + env.unset(QLatin1String("PWD")); +} + ToolChain::CompilerFlags ClangToolChain::defaultCompilerFlags() const { return CompilerFlags(GnuExtensions | StandardC99 | StandardCxx11); diff --git a/src/plugins/projectexplorer/gcctoolchain.h b/src/plugins/projectexplorer/gcctoolchain.h index 4027453b46..e445d74b7e 100644 --- a/src/plugins/projectexplorer/gcctoolchain.h +++ b/src/plugins/projectexplorer/gcctoolchain.h @@ -158,6 +158,7 @@ public: ToolChain *clone() const; QList suggestedMkspecList() const; + void addToEnvironment(Utils::Environment &env) const; protected: virtual CompilerFlags defaultCompilerFlags() const; -- cgit v1.2.1