[cfe-commits] r140409 - in /cfe/trunk: docs/tools/clang.pod include/clang/Driver/Options.td lib/Driver/Driver.cpp

Daniel Dunbar daniel at zuster.org
Fri Sep 30 14:25:04 PDT 2011


To be honest, I had forgotten we already had implemented that.

I was being a bit lazy here (ok maybe more than a bit), I just wanted
to be able to test out the impact of being able to do the chdir() in
process and avoiding an extra process spawn. To properly fix this to
use -working-directory= (and guarantee no behavior change) will take a
bit more work, as there are:
(a) a few places in the driver that access the file system.
(b) the driver will have to do something to honor that option when it
is calling out to other processes (like the linker), or be able to
adjust paths.

I think for now I'm going to just revert my patch and think about this more.

 - Daniel

On Fri, Sep 23, 2011 at 1:44 PM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Sep 23, 2011, at 1:33 PM, Daniel Dunbar wrote:
>
> Author: ddunbar
> Date: Fri Sep 23 15:33:41 2011
> New Revision: 140409
>
> URL: http://llvm.org/viewvc/llvm-project?rev=140409&view=rev
> Log:
> Driver: Add a --working-directory option which can be used to cause the
> compiler
> to operate "as if" in a certain working directory.
> - For now, we just implement this by changing the actual working directory,
> but
>   eventually we would want to handle this transparently. This is useful to
>   avoid an extra exec() pair in some situations, and will be something we
> would
>   want to support for more flexibility in using the Clang libraries.
>
> Modified:
>    cfe/trunk/docs/tools/clang.pod
>    cfe/trunk/include/clang/Driver/Options.td
>    cfe/trunk/lib/Driver/Driver.cpp
>
> Modified: cfe/trunk/docs/tools/clang.pod
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/clang.pod?rev=140409&r1=140408&r2=140409&view=diff
> ==============================================================================
> --- cfe/trunk/docs/tools/clang.pod (original)
> +++ cfe/trunk/docs/tools/clang.pod Fri Sep 23 15:33:41 2011
> @@ -407,6 +407,13 @@
>
> Show commands to run and use verbose output.
>
> +=item B<--working-directory>
> +
> +Use the given argument as the effective working directory to run the
> compiler
> +in. This is useful for running the compiler as if in a specific working
> +directory without the overhead of having to change directory using an
> auxiliary
> +process.
> +
> =back
>
>
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=140409&r1=140408&r2=140409&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Fri Sep 23 15:33:41 2011
> @@ -855,6 +855,8 @@
> def _version : Flag<"--version">;
> def _warn__EQ : Joined<"--warn-=">, Alias<W_Joined>;
> def _warn_ : Joined<"--warn-">, Alias<W_Joined>;
> +def _working_directory : Separate<"--working-directory">,
> +    HelpText<"Use the given argument as the effective working directory">;
> def _write_dependencies : Flag<"--write-dependencies">, Alias<MD>;
> def _write_user_dependencies : Flag<"--write-user-dependencies">,
> Alias<MMD>;
> def _ : Joined<"--">, Flags<[Unsupported]>;
>
> Err… why not make use of the existing option?
> def working_directory : Separate<"-working-directory">,
>   HelpText<"Resolve file paths relative to the specified directory">;
> def working_directory_EQ : Joined<"-working-directory=">,
>   Alias<working_directory>;
> Introduced in r118203, this teaches the various FileManagers and such to use
> an alternate working directory.
> - Doug
>




More information about the cfe-commits mailing list