[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-11 Thread Neil Henning via cfe-commits
sheredom wrote: Ok already need some advice after hacking! - `-working-directory` is only used by the **non** `-cc1` clang driver path. - But the VFS is only initialized way deep once you are in the `-cc1` path. - The problem is that just after `-working-directory` is set, we then use it to que

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-11 Thread Neil Henning via cfe-commits
sheredom wrote: > Right, that's what I meant by "Is it trying to set it too early before the > VFS is created or something?". We could make the driver setup the VFS like > the frontend would and do that before checking the -working-directory; not > sure if there's a reason we don't do that alr

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-11 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: Right, that's what I meant by "Is it trying to set it too early before the VFS is created or something?". We could make the driver setup the VFS like the frontend would and do that before checking the -working-directory; not sure if there's a reason we don't do that already

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-11 Thread Neil Henning via cfe-commits
sheredom wrote: So you can see [in Driver.cpp:1292](https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/Driver.cpp#L1292) that it will pass on any set `-working-directory` option to the VFS, but at this point the VFS is a `RealFileSystem`, which means it gets to [VirtualFileSystem

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-11 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: @sheredom I think I'm missing something. What's the actual failure? Setting `-working-directory` causes `FileManager` to prepend to paths the configured directory, so the VFS lookups would then be absolute paths not relative. I see the driver checks if the path in `-working

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-11 Thread Neil Henning via cfe-commits
sheredom wrote: > > We tried setting -working-directory=Z:/working, but the VFS requires that > > this is a real path. > > What error are you seeing if it's not? Is it trying to set it too early > before the VFS is created or something? The VFS doesn't actually override the set current workin

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-11 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: > We tried setting -working-directory=Z:/working, but the VFS requires that > this is a real path. What error are you seeing if it's not? Is it trying to set it too early before the VFS is created or something? https://github.com/llvm/llvm-project/pull/106577 __

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-10 Thread Henrik Karlsson via cfe-commits
honkstar1 wrote: Adding to @sheredom ... the precompiled headers are actually portable now (hurray!).. the single last non-virtual path we see is in the object files (.o). And it is related to the working dir as mentioned. https://github.com/llvm/llvm-project/pull/106577 _

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-10 Thread Neil Henning via cfe-commits
sheredom wrote: Ok by specifying `-resource-dir=Z:/resource` and adding it a VFS made that work. But we are seeing a single stray original path in the source files that we think is related to the working directory. We tried setting `-working-directory=Z:/working`, but the VFS requires that thi

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-10 Thread Neil Henning via cfe-commits
sheredom wrote: So we've been digging a bit further - I think its the `ResourceDir` path that is getting messed up. Even with the VFS it is using the location of clang to get the clang headers, which don't then get remapped. Will try and make a test for it. https://github.com/llvm/llvm-projec

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-08 Thread Henrik Karlsson via cfe-commits
honkstar1 wrote: I'm working with Neil and I've just tried changing our system to work the way where all our rsp etc use virtual paths and then create a vfsoverlay that points to the "right" places... it almost works for portable pch. What is not working is "#include_next".. that gets resolved

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-04 Thread Neil Henning via cfe-commits
sheredom wrote: > > Build machine A with a path E:/foo/header.h which wants to make a PCH from > > it. We want it to remap E:/foo -> Z:/fake. > > What I have in mind is that you have a VFS on build machine A that maps > Z:/fake (virtual path) -> E:/foo (external path), with use-external-names:

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-04 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: > Build machine A with a path E:/foo/header.h which wants to make a PCH from > it. We want it to remap E:/foo -> Z:/fake. What I have in mind is that you have a VFS on build machine A that maps Z:/fake (virtual path) -> E:/foo (external path), with use-external-names: false.

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-04 Thread Neil Henning via cfe-commits
sheredom wrote: > I think it's something much earlier in clang is not using the VFS at all when > looking up the main input path, so then it only knows the external path for > that case. My guess is that if that were fixed then the ASTWriter/Reader > would do the right thing here. I don't thi

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-04 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: I think it's something much earlier in clang is not using the VFS at all when looking up the main input path, so then it only knows the external path for that case. My guess is that if that were fixed then the ASTWriter/Reader would do the right thing here. https://githu

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-04 Thread Neil Henning via cfe-commits
sheredom wrote: > > `-emit-pch -o "%t.pch" %t/From/../From/B.h` > > > `'could not find file > > 'D:\llvm-project\build\tools\clang\test\VFS\Output\remap-to-fake.c.tmp\From\..\From\B.h'` > > Isn't that the same issue I mentioned, that it doesn't appear to work for the > main PCH input file? If

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-04 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: > `-emit-pch -o "%t.pch" %t/From/../From/B.h` > `'could not find file > 'D:\llvm-project\build\tools\clang\test\VFS\Output\remap-to-fake.c.tmp\From\..\From\B.h'` Isn't that the same issue I mentioned, that it doesn't appear to work for the main PCH input file? If you remov

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-10-02 Thread Neil Henning via cfe-commits
sheredom wrote: > It looks like it almost works: if I create a module in a virtual path and use > `use-external-names: false`, then the module stores the virtual path for its > input files. > > E.g. > > ``` > { > "version": 0, > "use-external-names": false, > "roots": [ > { >

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-30 Thread Ben Langmuir via cfe-commits
benlangmuir wrote: It looks like it almost works: if I create a module in a virtual path and use `use-external-names: false`, then the module stores the virtual path for its input files. E.g. ``` { "version": 0, "use-external-names": false, "roots": [ { "contents": [

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-25 Thread Neil Henning via cfe-commits
sheredom wrote: > > If the goal is to put virtual paths in the PCH so that you can map them > > somewhere else in the consuming compiler's VFS, does > > the`RedirectingFileSystem` setting `'use-external-names': false` do what > > you need? The idea behind that setting is that we would use the

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-25 Thread Neil Henning via cfe-commits
sheredom wrote: > Sorry for being slow to look at this in more detail: No bother! > > When generating a PCH map the original directory to some fake directory. > > You could imagine D:/Foo being mapped to Z:/Foo for instance. > > Can you clarify what this means? Is `Z:/Foo` a virtual-only pat

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-24 Thread Ben Langmuir via cfe-commits
https://github.com/benlangmuir commented: Sorry for being slow to look at this in more detail: > When generating a PCH map the original directory to some fake directory. You > could imagine D:/Foo being mapped to Z:/Foo for instance. Can you clarify what this means? Is `Z:/Foo` a virtual-only

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-24 Thread Neil Henning via cfe-commits
sheredom wrote: Any other comments or can I land this then? 😄 https://github.com/llvm/llvm-project/pull/106577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-16 Thread Neil Henning via cfe-commits
https://github.com/sheredom updated https://github.com/llvm/llvm-project/pull/106577 >From bbf433a5f56db6375e132b27bd4f7cd58feafe7b Mon Sep 17 00:00:00 2001 From: Neil Henning Date: Thu, 29 Aug 2024 13:15:49 +0100 Subject: [PATCH] Make PCH's respect any VFS specified. We want to be able to gen

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-16 Thread Neil Henning via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-13 Thread Ben Langmuir via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -4772,6 +4772,23 @@ bool ASTWriter::PreparePathForOutput(SmallVectorImpl &Path) { Changed = true; } + // If we are generating a normal PCH (EG. not a C++ module). + if (!WritingModule) { +// Use the vfs overlay if it exists to translate paths. +auto &FileSy

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t/From +// RUN: mkdir -p %t/To +// RUN: echo '#pragma once' > %t/From/B.h sheredom wrote: Never knew that existed and haven't used it before. But happy to port over for sure! https://github.com/llvm/llvm-pr

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -4772,6 +4772,23 @@ bool ASTWriter::PreparePathForOutput(SmallVectorImpl &Path) { Changed = true; } + // If we are generating a normal PCH (EG. not a C++ module). + if (!WritingModule) { +// Use the vfs overlay if it exists to translate paths. +auto &FileSy

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
@@ -4772,6 +4772,23 @@ bool ASTWriter::PreparePathForOutput(SmallVectorImpl &Path) { Changed = true; } + // If we are generating a normal PCH (EG. not a C++ module). + if (!WritingModule) { sheredom wrote: Note that without this guard the following t

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Ben Langmuir via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Neil Henning via cfe-commits
sheredom wrote: > Instead of using VFS overlays to make the AST file relocatable, have you > considered making use of `adjustFilenameForRelocatableAST()` (i.e. storing > relative paths to the AST file) and then setting the CWD accordingly when > loading? The problem we've got is that while we

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 commented: Instead of using VFS overlays to make the AST file relocatable, have you considered making use of `adjustFilenameForRelocatableAST()` (i.e. storing relative paths to the AST file) and then setting the CWD accordingly when loading? https://github.com/

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Jan Svoboda via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t/From +// RUN: mkdir -p %t/To +// RUN: echo '#pragma once' > %t/From/B.h jansvoboda11 wrote: Could you rewrite the test using `split-file`? That is much easier to read. https://github.com/llvm/llvm-project/

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-12 Thread Jan Svoboda via cfe-commits
@@ -4772,6 +4772,23 @@ bool ASTWriter::PreparePathForOutput(SmallVectorImpl &Path) { Changed = true; } + // If we are generating a normal PCH (EG. not a C++ module). + if (!WritingModule) { +// Use the vfs overlay if it exists to translate paths. +auto &FileSy

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-06 Thread Neil Henning via cfe-commits
https://github.com/sheredom updated https://github.com/llvm/llvm-project/pull/106577 >From 2d73b6c8463a36ec087fe66c2a48c3ae8fe5b05e Mon Sep 17 00:00:00 2001 From: Neil Henning Date: Thu, 29 Aug 2024 13:15:49 +0100 Subject: [PATCH] Make PCH's respect any VFS specified. We want to be able to gen

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-03 Thread Chris B via cfe-commits
@@ -4772,6 +4772,23 @@ bool ASTWriter::PreparePathForOutput(SmallVectorImpl &Path) { Changed = true; } + // If we are generating a normal PCH (EG. not a C++ module). + if (!WritingModule) { +// Use the vfs overlay if it exists to translate paths. +auto &FileSy

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-09-03 Thread Chris B via cfe-commits
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-08-29 Thread Neil Henning via cfe-commits
https://github.com/sheredom updated https://github.com/llvm/llvm-project/pull/106577 >From 774ca72fd61c98a830930dab9c60e16fcc6782a9 Mon Sep 17 00:00:00 2001 From: Neil Henning Date: Thu, 29 Aug 2024 13:15:49 +0100 Subject: [PATCH] Make PCH's respect any VFS specified. We want to be able to gen

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-08-29 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 175aa864f33786f3a6a4ee7381cbcafd0758501a e8e06cef736577eb098de57f8dfae201c945d2af --e

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-08-29 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Neil Henning (sheredom) Changes We want to be able to generate a PCH against one file-system path, and then re-use that PCH when the file-system path is different (but the sources are the same). We also do not know when generating the PCH

[clang] Make PCH's respect any VFS specified. (PR #106577)

2024-08-29 Thread Neil Henning via cfe-commits
https://github.com/sheredom created https://github.com/llvm/llvm-project/pull/106577 We want to be able to generate a PCH against one file-system path, and then re-use that PCH when the file-system path is different (but the sources are the same). We also do not know when generating the PCH wh