[PATCH] D91194: Fixes an issue where adding a relative path to the C include Directories via the C_INCLUDE_DIRS compile time option, there is a "/" ommitted to join the sysroot and the supplied relati

2020-11-10 Thread Lance Fredrickson via Phabricator via cfe-commits
lancethepants created this revision.
Herald added subscribers: cfe-commits, jgravelle-google, sbc100, dschuff.
Herald added a project: clang.
lancethepants requested review of this revision.
Herald added a subscriber: aheejin.

...the relative path of course does not start with "/", so the "/" is needed to 
properly join them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91194

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp

Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -331,9 +331,12 @@
 SmallVector dirs;
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+  if (llvm::sys::path::is_absolute(dir))
+addExternCSystemInclude(DriverArgs, CC1Args, dir);
+  else {
+addExternCSystemInclude(DriverArgs, CC1Args,
+StringRef(D.SysRoot) + "/" + dir);
+  }
 }
 return;
   }
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -245,9 +245,12 @@
 SmallVector dirs;
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+  if (llvm::sys::path::is_absolute(dir))
+addExternCSystemInclude(DriverArgs, CC1Args, dir);
+  else {
+addExternCSystemInclude(DriverArgs, CC1Args,
+StringRef(D.SysRoot) + "/" + dir);
+  }
 }
 return;
   }
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -274,9 +274,12 @@
 SmallVector dirs;
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+  if (llvm::sys::path::is_absolute(dir))
+addExternCSystemInclude(DriverArgs, CC1Args, dir);
+  else {
+addExternCSystemInclude(DriverArgs, CC1Args,
+StringRef(D.SysRoot) + "/" + dir);
+  }
 }
 return;
   }
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -578,9 +578,12 @@
 SmallVector dirs;
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+  if (llvm::sys::path::is_absolute(dir))
+addExternCSystemInclude(DriverArgs, CC1Args, dir);
+  else {
+addExternCSystemInclude(DriverArgs, CC1Args,
+StringRef(SysRoot) + "/" + dir);
+  }
 }
 return;
   }
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -158,9 +158,12 @@
 SmallVector Dirs;
 CIncludeDirs.split(Dirs, ":");
 for (StringRef Dir : Dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(Dir) ? "" : StringRef(SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + Dir);
+  if (llvm::sys::path::is_absolute(Dir))
+addExternCSystemInclude(DriverArgs, CC1Args, Dir);
+  else {
+addExternCSystemInclude(DriverArgs, CC1Args,
+StringRef(SysRoot) + "/" + Dir);
+  }
 }
 return;
   }
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -296,9 +296,12 @@
 SmallVector dirs;
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+  if (llvm::sys::p

[PATCH] D93164: [AST] Add generator for source location introspection

2022-01-18 Thread Lance Fredrickson via Phabricator via cfe-commits
lancethepants added a comment.

In D93164#3048130 , @lancethepants 
wrote:

> In D93164#2653067 , @mgorny wrote:
>
>> This change breaks cross-compilation now, as it tries running an executable 
>> built for the target system:
>>
>>   FAILED: tools/clang/lib/Tooling/ASTNodeAPI.json 
>>   cd /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling && 
>> /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump --skip-processing=0 
>> --astheader=/home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTTU.cpp
>>  -I /home/mgorny/llvm-project/build.arm64/lib/clang/13.0.0/include -I 
>> /home/mgorny/llvm-project/llvm/../clang/include -I 
>> /home/mgorny/llvm-project/build.arm64/tools/clang/include -I 
>> /home/mgorny/llvm-project/build.arm64/include -I 
>> /home/mgorny/llvm-project/llvm/include -I /sysroot/arm64/usr/include/c++/v1 
>> -I /usr/lib/clang/11.0.1/include -I /sysroot/arm64/usr/include 
>> --json-output-path 
>> /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTNodeAPI.json
>>   /bin/sh: /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump: Exec 
>> format error
>>
>> I guess you can look at TableGens how to correctly generate and use host 
>> executables.
>
> I am now running into this error now that clang13 has released.  I cannot 
> figure a way around this. I do not see any cmake options similar to the 
> tablegens that allow you to specify the binary for the build system.  Am I 
> missing something or is clang13 just broken for cross compilation?



In D93164#3250945 , @andrew-wja wrote:

> In D93164#3048130 , @lancethepants 
> wrote:
>
>> In D93164#2653067 , @mgorny wrote:
>>
>>> This change breaks cross-compilation now, as it tries running an executable 
>>> built for the target system:
>>>
>>>   FAILED: tools/clang/lib/Tooling/ASTNodeAPI.json 
>>>   cd /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling && 
>>> /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump 
>>> --skip-processing=0 
>>> --astheader=/home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTTU.cpp
>>>  -I /home/mgorny/llvm-project/build.arm64/lib/clang/13.0.0/include -I 
>>> /home/mgorny/llvm-project/llvm/../clang/include -I 
>>> /home/mgorny/llvm-project/build.arm64/tools/clang/include -I 
>>> /home/mgorny/llvm-project/build.arm64/include -I 
>>> /home/mgorny/llvm-project/llvm/include -I /sysroot/arm64/usr/include/c++/v1 
>>> -I /usr/lib/clang/11.0.1/include -I /sysroot/arm64/usr/include 
>>> --json-output-path 
>>> /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTNodeAPI.json
>>>   /bin/sh: /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump: Exec 
>>> format error
>>>
>>> I guess you can look at TableGens how to correctly generate and use host 
>>> executables.
>>
>> I am now running into this error now that clang13 has released.  I cannot 
>> figure a way around this. I do not see any cmake options similar to the 
>> tablegens that allow you to specify the binary for the build system.  Am I 
>> missing something or is clang13 just broken for cross compilation?
>
> Another confirmation that this change has broken cross compilation. I have 
> tried setting both `-DCLANG_TOOLING_BUILD_AST_INTROSPECTION=OFF` and 
> `-DCMAKE_CROSSCOMPILING=ON` separately and in combination. This means that 
> LLVM cannot be cross compiled for AArch64, which is a pretty serious problem!



In D93164#3250945 , @andrew-wja wrote:

> In D93164#3048130 , @lancethepants 
> wrote:
>
>> In D93164#2653067 , @mgorny wrote:
>>
>>> This change breaks cross-compilation now, as it tries running an executable 
>>> built for the target system:
>>>
>>>   FAILED: tools/clang/lib/Tooling/ASTNodeAPI.json 
>>>   cd /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling && 
>>> /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump 
>>> --skip-processing=0 
>>> --astheader=/home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTTU.cpp
>>>  -I /home/mgorny/llvm-project/build.arm64/lib/clang/13.0.0/include -I 
>>> /home/mgorny/llvm-project/llvm/../clang/include -I 
>>> /home/mgorny/llvm-project/build.arm64/tools/clang/include -I 
>>> /home/mgorny/llvm-project/build.arm64/include -I 
>>> /home/mgorny/llvm-project/llvm/include -I /sysroot/arm64/usr/include/c++/v1 
>>> -I /usr/lib/clang/11.0.1/include -I /sysroot/arm64/usr/include 
>>> --json-output-path 
>>> /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTNodeAPI.json
>>>   /bin/sh: /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump: Exec 
>>> format error
>>>
>>> I guess you can look at TableGens how to correctly generate and use host 
>>> executables.
>>
>> I am now running int

[PATCH] D93164: [AST] Add generator for source location introspection

2022-01-19 Thread Lance Fredrickson via Phabricator via cfe-commits
lancethepants added a comment.

> @lancethepants @smeenai thanks for the pointers! Unfortunately, it still 
> doesn't work for me after passing -DCMAKE_SYSTEM_NAME="Linux". Passing that 
> option did change the CMake output, so it's definitely recognized at least 
> (the messages about which sanitizer tests will run now call the platform 
> "Linux" as opposed to referring to the platform as default). I am also 
> compiling on Linux for Linux, I'm just trying to build an AArch64 toolchain 
> which I can copy to an SD card for testing on an AArch64 board. 
> @lancethepants could you check your CMake version where you got this to work? 
> I'm using CMake 3.22.1 and trying to build llvmorg-13.0.0
>
> The full invocation I'm using is the following:
>
>   cmake -G Ninja \
> -DLLVM_TABLEGEN=${TOP}/${CLANG_TBLGEN_DIR}/bin/llvm-tblgen \
> -DCLANG_TABLEGEN=${TOP}/${CLANG_TBLGEN_DIR}/bin/clang-tblgen \
> -DCMAKE_SYSTEM_NAME="Linux" \
> -DCMAKE_CROSSCOMPILING=ON \
> -DCLANG_TOOLING_BUILD_AST_INTROSPECTION=OFF \
> -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
> -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
> -DCMAKE_BUILD_TYPE=MinSizeRel \
> -DCMAKE_INSTALL_PREFIX=${TOP}/${ROOT_DIR} \
> -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu \
> -DLLVM_NATIVE_ARCH="X86" \
> -DLLVM_TARGET_ARCH="AArch64" \
> -DLLVM_TARGETS_TO_BUILD="AArch64" \
> -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld;" \
> -DLLVM_ENABLE_TERMINFO=OFF \
> -DLLVM_ENABLE_BINDINGS=OFF \
> -DLLVM_BUILD_EXAMPLES=OFF \
> -DLLVM_BUILD_TESTS=OFF \
> -DLLVM_BUILD_BENCHMARKS=OFF \
> ${TOP}/${SRC_DIR}/llvm/

Are you stil encountering the same issue?
This is my cmake invocation.
https://github.com/lancethepants/tomatoware/blob/master/scripts/buildroot.sh#L808-L843

I typically update cmake to the most recent whenver I get around to updating my 
project. The latest I've used is 3.21.4. Looks like you're using the very 
newest, so I doubt it's the difference between my version and your version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93164/new/

https://reviews.llvm.org/D93164

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93164: [AST] Add generator for source location introspection

2021-10-07 Thread Lance Fredrickson via Phabricator via cfe-commits
lancethepants added a comment.

In D93164#2653067 , @mgorny wrote:

> This change breaks cross-compilation now, as it tries running an executable 
> built for the target system:
>
>   FAILED: tools/clang/lib/Tooling/ASTNodeAPI.json 
>   cd /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling && 
> /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump --skip-processing=0 
> --astheader=/home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTTU.cpp
>  -I /home/mgorny/llvm-project/build.arm64/lib/clang/13.0.0/include -I 
> /home/mgorny/llvm-project/llvm/../clang/include -I 
> /home/mgorny/llvm-project/build.arm64/tools/clang/include -I 
> /home/mgorny/llvm-project/build.arm64/include -I 
> /home/mgorny/llvm-project/llvm/include -I /sysroot/arm64/usr/include/c++/v1 
> -I /usr/lib/clang/11.0.1/include -I /sysroot/arm64/usr/include 
> --json-output-path 
> /home/mgorny/llvm-project/build.arm64/tools/clang/lib/Tooling/ASTNodeAPI.json
>   /bin/sh: /home/mgorny/llvm-project/build.arm64/bin/clang-ast-dump: Exec 
> format error
>
> I guess you can look at TableGens how to correctly generate and use host 
> executables.

I am now running into this error now that clang13 has released.  I cannot 
figure a way around this. I do not see any cmake options similar to the 
tablegens that allow you to specify the binary for the build system.  Am I 
missing something or is clang13 just broken for cross compilation?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93164/new/

https://reviews.llvm.org/D93164

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits