Enforce PWD in the environment of build steps

In the shell PWD can be different from the "real" working directory,
because the latter never contains symbolic links (getcwd).
E.g. Clang uses PWD as the basis for debug information.

Fixes: QTCREATORBUG-23788
Change-Id: I19f06dcfded5ccca2dc0162a3a543cdc756bffb0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2020-04-21 11:36:24 +02:00
parent 2e8cb8c901
commit 5838b40c6d

View File

@@ -236,7 +236,12 @@ void AbstractProcessStep::doRun()
d->m_process.reset(new Utils::QtcProcess());
d->m_process->setUseCtrlCStub(Utils::HostOsInfo::isWindowsHost());
d->m_process->setWorkingDirectory(wd.absolutePath());
d->m_process->setEnvironment(d->m_param.environment());
// Enforce PWD in the environment because some build tools use that.
// PWD can be different from getcwd in case of symbolic links (getcwd resolves symlinks).
// For example Clang uses PWD for paths in debug info, see QTCREATORBUG-23788
Environment envWithPwd = d->m_param.environment();
envWithPwd.set("PWD", d->m_process->workingDirectory());
d->m_process->setEnvironment(envWithPwd);
d->m_process->setCommand(effectiveCommand);
if (d->m_lowPriority && ProjectExplorerPlugin::projectExplorerSettings().lowBuildPriority)
d->m_process->setLowPriority();