[Lldb-commits] [PATCH] D141042: [lldb] Allow configuring on Windows with python interpreter within a junction

2023-01-05 Thread Markus Böck via Phabricator via lldb-commits
zero9178 created this revision.
zero9178 added reviewers: JDevlieghere, lawrence_danna, clayborg, labath, 
jingham.
Herald added a project: All.
zero9178 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The current implementation nicely takes into account when the python 
interpreter is symlinked (or transitively within a symlinked directory). Sadly, 
`os.path.islink` returns `false` on Windows if instead of Windows symlinks, 
junctions are used. This has caused me issues after I started using `scoop` as 
my package manager on Windows, which creates junctions instead of symlinks.
The fix proposed in this patch is to check whether `realpath` returns a 
different path to `exe`, and if it does, to simply try again with that path. 
The code could also be simplified since `sys.executable` is guaranteed to be 
absolute, and `os.readlink`, which can return a relative path, is no longer 
used.

Tested on Windows 11 with Python 3.11 as interpereter and Ubuntu 18.04 with 
Python 3.6


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141042

Files:
  lldb/bindings/python/get-python-config.py


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -51,8 +51,10 @@
 break
 except ValueError:
 tried.append(exe)
-if os.path.islink(exe):
-exe = os.path.join(os.path.realpath(os.path.dirname(exe)), 
os.readlink(exe))
+# Retry if the executable is symlinked or similar.
+# This is roughly equal to os.path.islink, except it also 
works for junctions on Windows.
+if os.path.realpath(exe) != exe:
+exe = os.path.realpath(exe)
 continue
 else:
 print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -51,8 +51,10 @@
 break
 except ValueError:
 tried.append(exe)
-if os.path.islink(exe):
-exe = os.path.join(os.path.realpath(os.path.dirname(exe)), os.readlink(exe))
+# Retry if the executable is symlinked or similar.
+# This is roughly equal to os.path.islink, except it also works for junctions on Windows.
+if os.path.realpath(exe) != exe:
+exe = os.path.realpath(exe)
 continue
 else:
 print("Could not find a relative path to sys.executable under sys.prefix", file=sys.stderr)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D141042: [lldb] Allow configuring on Windows with python interpreter within a junction

2023-01-06 Thread Markus Böck via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e84e038447e: [lldb] Allow configuring on Windows with 
python interpreter within a junction (authored by zero9178).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141042

Files:
  lldb/bindings/python/get-python-config.py


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -51,8 +51,10 @@
 break
 except ValueError:
 tried.append(exe)
-if os.path.islink(exe):
-exe = os.path.join(os.path.realpath(os.path.dirname(exe)), 
os.readlink(exe))
+# Retry if the executable is symlinked or similar.
+# This is roughly equal to os.path.islink, except it also 
works for junctions on Windows.
+if os.path.realpath(exe) != exe:
+exe = os.path.realpath(exe)
 continue
 else:
 print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -51,8 +51,10 @@
 break
 except ValueError:
 tried.append(exe)
-if os.path.islink(exe):
-exe = os.path.join(os.path.realpath(os.path.dirname(exe)), os.readlink(exe))
+# Retry if the executable is symlinked or similar.
+# This is roughly equal to os.path.islink, except it also works for junctions on Windows.
+if os.path.realpath(exe) != exe:
+exe = os.path.realpath(exe)
 continue
 else:
 print("Could not find a relative path to sys.executable under sys.prefix", file=sys.stderr)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Markus Böck via Phabricator via lldb-commits
zero9178 created this revision.
zero9178 added reviewers: phosek, hans, MaskRay, compnerd.
Herald added subscribers: arphaman, mgorny.
zero9178 requested review of this revision.
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Linking against the LibXml2::LibXml2 target has the advantage of not only 
importing the library, but also adding the include path as well as any 
definitions the library requires. In case of a static build of libxml2, eg. a 
define is set on Windows to remove any DLL imports and export.

LLVM already makes use of the target, but c-index-test and lldb were still 
linking against the library only.

The workaround for Mac OS-X that I removed seems to have also been made 
redundant since https://reviews.llvm.org/D84563 I believe


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109975

Files:
  clang/tools/c-index-test/CMakeLists.txt
  lldb/source/Host/CMakeLists.txt


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Markus Böck via Phabricator via lldb-commits
zero9178 added a comment.

In D109975#3006580 , @Quuxplusone 
wrote:

> Serendipitously, I just yesterday upgraded from OSX 10.14 to 10.15, and have 
> been unable to build clang because, even with a totally-empty-and-brand-new 
> build directory, CMake says:
>
>   CMake Error in lib/WindowsManifest/CMakeLists.txt:
> Imported target "LibXml2::LibXml2" includes non-existent path
>   
> "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2"
> in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
> * The path was deleted, renamed, or moved to another location.
> * An install or uninstall procedure did not complete successfully.
> * The installation package was faulty and references files it does not
> provide.
>   -- Generating done
>   CMake Generate step failed.  Build files cannot be regenerated correctly.
>
> Do you think this PR would fix that issue on OSX 10.15?
> (IMHO it's also weird that OSX would even be trying to build anything with 
> `Windows` in the name.)

Since there is nothing platform specific in the code of WindowsManifest it'd 
make sense to build it on any OS; At the very least for cross compile setups.

I sadly am not very accustomed to Macs so I don't know the details, but I don't 
think this patch would change anything about your situation.

Could it maybe be related to the `CMAKE_OSX_SYSROOT` variable somehow? CMake 
seems to use it to lookup packages from the platform SDK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

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


[Lldb-commits] [PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-25 Thread Markus Böck via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b61f43b6096: [CMake] Consistently use the LibXml2::LibXml2 
target instead of… (authored by zero9178).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

Files:
  clang/tools/c-index-test/CMakeLists.txt
  lldb/source/Host/CMakeLists.txt


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits