[llvm-branch-commits] [compiler-rt] release/18.x: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) (PR #81402)
petrhosek wrote: > @petrhosek What do you think about merging this PR to the release branch? LGTM https://github.com/llvm/llvm-project/pull/81402 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [cmake] Reenable FatLTO for Fuchsia toolchains (PR #85709)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/85709 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,7 @@ +set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root petrhosek wrote: This variable seems unused and has the same value as `MLIR_INCLUDE_DIR` below, what's the use case for this variable? https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,7 @@ +set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root +set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir +set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) +include_directories(SYSTEM ${MLIR_INCLUDE_DIR}) +include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR}) petrhosek wrote: Why do these need to be system include directories? Rather than adding these to global list of include paths, could we create an interface library and use it as an explicit dependency only for targets that need it? https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [sanitizer_symbolizer] Add initial symbolizer markup support for linux. (PR #73193)
@@ -275,3 +275,7 @@ COMMON_FLAG(bool, test_only_emulate_no_memorymap, false, // program. COMMON_FLAG(bool, test_only_replace_dlopen_main_program, false, "TEST ONLY replace dlopen(,...) with dlopen(NULL)") + +COMMON_FLAG(bool, enable_symbolizer_markup, SANITIZER_FUCHSIA, +"Use sanitizer symbolizer markup, available on Linux " +"and always set true for fuchsia.") petrhosek wrote: Super minor nit, but `Fuchsia` should be capitalized. https://github.com/llvm/llvm-project/pull/73193 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] release/19.x: [compiler-rt] Support building runtimes for Windows on arm32 (#101462) (PR #106518)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/106518 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] [profile] Change __llvm_profile_counter_bias type to match llvm (PR #107362)
petrhosek wrote: I agree, while the risk is low, this issue has existed for several releases so it should fine do delay the fix a bit further. https://github.com/llvm/llvm-project/pull/107362 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] b014335 - [libc] Distinguish compiler and run failures
Author: Petr Hosek Date: 2021-01-21T15:27:34-08:00 New Revision: b0143352634ba7ed29f1db6ea576c0abfd0b4a29 URL: https://github.com/llvm/llvm-project/commit/b0143352634ba7ed29f1db6ea576c0abfd0b4a29 DIFF: https://github.com/llvm/llvm-project/commit/b0143352634ba7ed29f1db6ea576c0abfd0b4a29.diff LOG: [libc] Distinguish compiler and run failures This is useful for debugging issues, for example when cross-compiling. Differential Revision: https://reviews.llvm.org/D95118 Added: Modified: libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake Removed: diff --git a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake index 86c3822c864c..57dfbd9731d6 100644 --- a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake +++ b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake @@ -115,12 +115,14 @@ function(_check_defined_cpu_feature output_var) COMPILE_DEFINITIONS ${flags} COMPILE_OUTPUT_VARIABLE compile_output RUN_OUTPUT_VARIABLE run_output) - if(${compile_result} AND ("${run_result}" EQUAL 0)) + if("${run_result}" EQUAL 0) set(${output_var} "${run_output}" PARENT_SCOPE) + elseif(NOT ${compile_result}) +message(FATAL_ERROR "Failed to compile: ${compile_output}") else() -message(FATAL_ERROR "${compile_output}") +message(FATAL_ERROR "Failed to run: ${run_output}") endif() endfunction() ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] f67d3db - [clang] - Also look for devtoolset-10
Author: Petr Hosek Date: 2021-01-04T14:24:46-08:00 New Revision: f67d3dbdb930eaf92668b47696e51ef0b2c3c3a5 URL: https://github.com/llvm/llvm-project/commit/f67d3dbdb930eaf92668b47696e51ef0b2c3c3a5 DIFF: https://github.com/llvm/llvm-project/commit/f67d3dbdb930eaf92668b47696e51ef0b2c3c3a5.diff LOG: [clang] - Also look for devtoolset-10 devtoolset-10 has just been released so look for it as well. Patch By: stephan.dollberg Differential Revision: https://reviews.llvm.org/D92792 Added: Modified: clang/lib/Driver/ToolChains/Gnu.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 4a075b12d1af..336ee13b2df5 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2049,6 +2049,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( // Non-Solaris is much simpler - most systems just go with "/usr". if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) { // Yet, still look for RHEL devtoolsets. +Prefixes.push_back("/opt/rh/devtoolset-10/root/usr"); Prefixes.push_back("/opt/rh/devtoolset-9/root/usr"); Prefixes.push_back("/opt/rh/devtoolset-8/root/usr"); Prefixes.push_back("/opt/rh/devtoolset-7/root/usr"); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] f32ff08 - [CMake][Fuchsia] Support for building with MSVC
Author: Petr Hosek Date: 2020-07-06T11:38:27-07:00 New Revision: f32ff0807e9e04e727f98804e6aff6c2353b4d73 URL: https://github.com/llvm/llvm-project/commit/f32ff0807e9e04e727f98804e6aff6c2353b4d73 DIFF: https://github.com/llvm/llvm-project/commit/f32ff0807e9e04e727f98804e6aff6c2353b4d73.diff LOG: [CMake][Fuchsia] Support for building with MSVC This change adds the necessary flags for building the full Fuchsia toolchain on Windows with MSVC. Differential Revision: https://reviews.llvm.org/D73810 Added: Modified: clang/cmake/caches/Fuchsia-stage2.cmake clang/cmake/caches/Fuchsia.cmake Removed: diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index 9ecf8f300e75..f7a1e5ca8ad6 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -22,6 +22,10 @@ set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "") set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "") set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "") +if(MSVC) + set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "") +endif() + set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") if(NOT APPLE) set(CLANG_DEFAULT_LINKER lld CACHE STRING "") @@ -39,6 +43,8 @@ set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") set(CMAKE_BUILD_TYPE Release CACHE STRING "") if (APPLE) set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "") +elseif(MSVC) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "") endif() if(APPLE) @@ -67,12 +73,32 @@ if(APPLE) set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "") endif() +if(MSVC) + set(target "x86_64-pc-windows-msvc") + + list(APPEND BUILTIN_TARGETS "${target}") + set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "") + set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") + + list(APPEND RUNTIME_TARGETS "${target}") + set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "") +endif() + foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu) if(LINUX_${target}_SYSROOT) # Set the per-target builtins options. list(APPEND BUILTIN_TARGETS "${target}") set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") +set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "") +set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "") +set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "") set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -82,6 +108,9 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn list(APPEND RUNTIME_TARGETS "${target}") set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") +set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "") +set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "") +set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "") set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -103,6 +132,7 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "") set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") +set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") # Use .build-id link. list(APPEND RUNTIME_BUILD_ID_LINK "${target}") @@ -115,7 +145,7 @@ if(FUCHSIA_SDK) set(FUCHSIA_x86_64_NAME x64) set(FUCHSIA_riscv64_NAME riscv64) foreach(target i386;x86_64;aarch64;riscv64) -set(FUCHSIA_${target}_COMPILER_FLAGS "-I${FUCHSIA_SDK}/pkg/fdio/include") +set(FUCHSIA_${target
[llvm-branch-commits] [llvm][fatlto] Drop any CFI related instrumentation after emitting bitcode (PR #112788)
@@ -1629,6 +1629,10 @@ PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO, MPM.addPass(buildLTOPreLinkDefaultPipeline(Level)); MPM.addPass(EmbedBitcodePass(ThinLTO, EmitSummary)); + // If we're doing FatLTO w/ CFI enabled, we don't want the type tests in the + // object file. + MPM.addPass(LowerTypeTestsPass(nullptr, nullptr, true, true)); petrhosek wrote: This PR depends on #112787 which adds the fourth argument. https://github.com/llvm/llvm-project/pull/112788 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/19.x: [Clang][perf-training] Fix clean command in perf-helper.py (#118978) (PR #119051)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/119051 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Make `--repository` change the HTML output (PR #122566)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/122566 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Make `--repository` change the HTML output (PR #122566)
@@ -494,18 +494,31 @@ genReferencesBlock(const std::vector &References, static std::unique_ptr writeFileDefinition(const Location &L, std::optional RepositoryUrl = std::nullopt) { - if (!L.IsFileInRootDir || !RepositoryUrl) + if (!L.IsFileInRootDir && !RepositoryUrl) return std::make_unique( HTMLTag::TAG_P, "Defined at line " + std::to_string(L.LineNumber) + " of file " + L.Filename); SmallString<128> FileURL(*RepositoryUrl); - llvm::sys::path::append(FileURL, llvm::sys::path::Style::posix, L.Filename); + llvm::sys::path::append( + FileURL, llvm::sys::path::Style::posix, + // If we're on windows, the file name will be in the wrong format, and petrhosek wrote: ```suggestion // If we're on Windows, the file name will be in the wrong format, and ``` https://github.com/llvm/llvm-project/pull/122566 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)
@@ -0,0 +1,226 @@ +#===-- CMakeLists.txt --===# +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +#======# +# +# Build instructions for the flang-rt library. This is file is intended to be +# included using the LLVM_ENABLE_RUNTIMES mechanism. +# +#======# + +set(LLVM_SUBPROJECT_TITLE "Fortran Runtime") +set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(FLANG_RT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") +set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang") + + +# CMake 3.24 is the first version of CMake that directly recognizes Flang. +# LLVM's requirement is only CMake 3.20, teach CMake 3.20-3.23 how to use Flang. +if (CMAKE_VERSION VERSION_LESS "3.24") + cmake_path(GET CMAKE_Fortran_COMPILER STEM _Fortran_COMPILER_STEM) + if (_Fortran_COMPILER_STEM STREQUAL "flang-new" OR _Fortran_COMPILER_STEM STREQUAL "flang") +include(CMakeForceCompiler) +CMAKE_FORCE_Fortran_COMPILER("${CMAKE_Fortran_COMPILER}" "LLVMFlang") + +set(CMAKE_Fortran_COMPILER_ID "LLVMFlang") +set(CMAKE_Fortran_COMPILER_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") + +set(CMAKE_Fortran_SUBMODULE_SEP "-") +set(CMAKE_Fortran_SUBMODULE_EXT ".mod") + +set(CMAKE_Fortran_PREPROCESS_SOURCE + " -cpp-E > ") + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + +set(CMAKE_Fortran_MODDIR_FLAG "-module-dir") + +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp") +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp") +set(CMAKE_Fortran_POSTPROCESS_FLAG "-ffixed-line-length-72") + +set(CMAKE_Fortran_COMPILE_OPTIONS_TARGET "--target=") + +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",") + endif () +endif () +enable_language(Fortran) + + +list(APPEND CMAKE_MODULE_PATH +"${FLANG_RT_SOURCE_DIR}/cmake/modules" +"${FLANG_SOURCE_DIR}/cmake/modules" + ) +include(AddFlangRT) +include(FlangCommon) + + + +# Build Mode Introspection # + + +# Setting these variables from an LLVM build is sufficient that flang-rt can +# construct the output paths, so it can behave as if it was in-tree here. +set(LLVM_TREE_AVAILABLE OFF) +if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION) + # This is a bootstap build + set(LLVM_TREE_AVAILABLE ON) +endif() + +# Path to LLVM development tools (FileCheck, llvm-lit, not, ...) +set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin") + +if (LLVM_TREE_AVAILABLE) + # In a bootstrap build emit the libraries into a default search path in the + # build directory of the just-built compiler. This allows using the + # just-built compiler without specifying paths to runtime libraries. + # + # Despite Clang in the name, get_clang_resource_dir does not depend on Clang + # being added to the build. Flang uses the same resource dir as clang. + include(GetClangResourceDir) + get_clang_resource_dir(FLANG_RT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") + get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself +else () + # In a runtimes build never write into LLVM's build dir. It might be reused + # for mutliple Flang-RT builds (e.g. Debug/Release). Instead create our own + # library directory. + # + # TODO: Support multi-config generators + set(FLANG_RT_BUILD_LIB_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") + set(FLANG_RT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}") +endif () + +if (DEFINED WIN32) + set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/windows") + set(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_LIB_DIR}/windows") +elseif (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) + set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}") + set(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}") +endif () + + +# +# Build Options # +# + +# Important: flang-rt user options must be prefixed with "FLANG_RT_". Variables +# with this prefix will be forwarded in bootstrap builds. + +option(FLANG_RT_INCLUDE_TESTS "Generate build targets for the flang-rt unit and regression-tests." "${LLVM_INCLUDE_TESTS}") + + +set(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile Flang-RT with GPU support (CUDA or OpenMP)") +set_property(CACHE FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS +"" +CUDA +OpenMP + ) +if (NOT FLANG_RT_EXPERIMENTAL_O
[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)
https://github.com/petrhosek edited https://github.com/llvm/llvm-project/pull/110217 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)
@@ -0,0 +1,226 @@ +#===-- CMakeLists.txt --===# +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +#======# +# +# Build instructions for the flang-rt library. This is file is intended to be +# included using the LLVM_ENABLE_RUNTIMES mechanism. +# +#======# + +set(LLVM_SUBPROJECT_TITLE "Fortran Runtime") +set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(FLANG_RT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") +set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang") + + +# CMake 3.24 is the first version of CMake that directly recognizes Flang. +# LLVM's requirement is only CMake 3.20, teach CMake 3.20-3.23 how to use Flang. +if (CMAKE_VERSION VERSION_LESS "3.24") + cmake_path(GET CMAKE_Fortran_COMPILER STEM _Fortran_COMPILER_STEM) + if (_Fortran_COMPILER_STEM STREQUAL "flang-new" OR _Fortran_COMPILER_STEM STREQUAL "flang") +include(CMakeForceCompiler) +CMAKE_FORCE_Fortran_COMPILER("${CMAKE_Fortran_COMPILER}" "LLVMFlang") + +set(CMAKE_Fortran_COMPILER_ID "LLVMFlang") +set(CMAKE_Fortran_COMPILER_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") + +set(CMAKE_Fortran_SUBMODULE_SEP "-") +set(CMAKE_Fortran_SUBMODULE_EXT ".mod") + +set(CMAKE_Fortran_PREPROCESS_SOURCE + " -cpp-E > ") + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + +set(CMAKE_Fortran_MODDIR_FLAG "-module-dir") + +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp") +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp") +set(CMAKE_Fortran_POSTPROCESS_FLAG "-ffixed-line-length-72") + +set(CMAKE_Fortran_COMPILE_OPTIONS_TARGET "--target=") + +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",") + endif () +endif () +enable_language(Fortran) + + +list(APPEND CMAKE_MODULE_PATH +"${FLANG_RT_SOURCE_DIR}/cmake/modules" +"${FLANG_SOURCE_DIR}/cmake/modules" + ) +include(AddFlangRT) +include(FlangCommon) + + + +# Build Mode Introspection # + + +# Setting these variables from an LLVM build is sufficient that flang-rt can +# construct the output paths, so it can behave as if it was in-tree here. +set(LLVM_TREE_AVAILABLE OFF) +if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION) + # This is a bootstap build + set(LLVM_TREE_AVAILABLE ON) +endif() + +# Path to LLVM development tools (FileCheck, llvm-lit, not, ...) +set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin") + +if (LLVM_TREE_AVAILABLE) + # In a bootstrap build emit the libraries into a default search path in the + # build directory of the just-built compiler. This allows using the + # just-built compiler without specifying paths to runtime libraries. + # + # Despite Clang in the name, get_clang_resource_dir does not depend on Clang + # being added to the build. Flang uses the same resource dir as clang. + include(GetClangResourceDir) + get_clang_resource_dir(FLANG_RT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") + get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself +else () + # In a runtimes build never write into LLVM's build dir. It might be reused + # for mutliple Flang-RT builds (e.g. Debug/Release). Instead create our own + # library directory. + # + # TODO: Support multi-config generators + set(FLANG_RT_BUILD_LIB_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") + set(FLANG_RT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}") +endif () + +if (DEFINED WIN32) + set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/windows") + set(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_LIB_DIR}/windows") petrhosek wrote: Is there a reason for not using target triple on Windows? https://github.com/llvm/llvm-project/pull/110217 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Use LangOpts when printing types (PR #120308)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/120308 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-doc][NFC] Use isa over dyn_cast (PR #120309)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/120309 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-doc] Use QualName in Markdown output (PR #119815)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/119815 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-doc][NFC] Make test resilient to line changes (PR #119811)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/119811 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-doc] Precommit test case for functions with templated parameters and return (PR #119814)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/119814 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-doc] Add tests for Markdown output with C++ templates (PR #119813)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/119813 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-doc] Add tests for Markdown output with C++ templates (PR #119813)
@@ -75,3 +89,8 @@ void function(bool x) {} // YAML-NEXT: - Contents:'0' // YAML-NEXT: ... +// MD: ### function +// MD: *void function(_Bool x)* +// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 27]]* + + petrhosek wrote: Nit: These extra empty lines shouldn't be needed. ```suggestion ``` https://github.com/llvm/llvm-project/pull/119813 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)
@@ -16,7 +16,7 @@ // C-AARCH64-BAREMETAL: "-cc1" "-triple" "aarch64-unknown-none-elf" // C-AARCH64-BAREMETAL: "-isysroot" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" // C-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include" -// C-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld" +// C-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld" "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" petrhosek wrote: Can you move the `--sysroot=` flags onto the newline to make this more readable? Same for all other cases in this PR. ```suggestion // C-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld" // C-AARCH64-BAREMETAL: "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" ``` https://github.com/llvm/llvm-project/pull/132808 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/132807 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/132808 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)
@@ -336,6 +336,26 @@ BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const { return llvm::reverse(Default); } +ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) petrhosek wrote: Could we make it conditional only on valid GCC installation? ```suggestion if (GCCInstallation.isValid()) ``` https://github.com/llvm/llvm-project/pull/121831 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)
@@ -336,6 +336,26 @@ BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const { return llvm::reverse(Default); } +ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) +return ToolChain::CST_Libstdcxx; + return ToolChain::CST_Libcxx; +} + +ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) +return ToolChain::RLT_Libgcc; + return ToolChain::RLT_CompilerRT; +} + +ToolChain::UnwindLibType +BareMetal::GetUnwindLibType(const llvm::opt::ArgList &Args) const { + if (getTriple().isRISCV()) +return ToolChain::UNW_None; petrhosek wrote: Shouldn't this return `UNW_Libgcc`? ```suggestion return ToolChain::UNW_Libgcc; ``` https://github.com/llvm/llvm-project/pull/121831 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)
@@ -336,6 +336,26 @@ BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const { return llvm::reverse(Default); } +ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) +return ToolChain::CST_Libstdcxx; + return ToolChain::CST_Libcxx; +} + +ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) +return ToolChain::RLT_Libgcc; + return ToolChain::RLT_CompilerRT; +} + +ToolChain::UnwindLibType +BareMetal::GetUnwindLibType(const llvm::opt::ArgList &Args) const { + if (getTriple().isRISCV()) petrhosek wrote: Could we make it conditional only on valid GCC installation? ```suggestion if (GCCInstallation.isValid()) ``` https://github.com/llvm/llvm-project/pull/121831 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)
@@ -534,8 +554,14 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-Bstatic"); - if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax)) -CmdArgs.push_back("--no-relax"); + if (Triple.isRISCV()) { +if (Args.hasArg(options::OPT_mno_relax)) + CmdArgs.push_back("--no-relax"); +CmdArgs.push_back("-m"); +CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv" +: "elf32lriscv"); +CmdArgs.push_back("-X"); + } petrhosek wrote: This would ideally be a separate PR which could land before the final removal of `RISCVToolchain`. https://github.com/llvm/llvm-project/pull/121831 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)
@@ -336,6 +336,26 @@ BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const { return llvm::reverse(Default); } +ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) +return ToolChain::CST_Libstdcxx; + return ToolChain::CST_Libcxx; +} + +ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) petrhosek wrote: Could we make it conditional only on valid GCC installation? ```suggestion if (GCCInstallation.isValid()) ``` https://github.com/llvm/llvm-project/pull/121831 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)
@@ -54,12 +54,11 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF { return UnwindTableLevel::None; } - RuntimeLibType GetDefaultRuntimeLibType() const override { -return ToolChain::RLT_CompilerRT; - } - CXXStdlibType GetDefaultCXXStdlibType() const override { -return ToolChain::CST_Libcxx; - } + CXXStdlibType GetDefaultCXXStdlibType() const override; + + RuntimeLibType GetDefaultRuntimeLibType() const override; + + UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const override; petrhosek wrote: These changes would ideally be separate from the final removal of the `RISCVToolchain` at which point that should be effectively a no-op. https://github.com/llvm/llvm-project/pull/121831 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Handle static members and functions (PR #135457)
@@ -729,6 +729,62 @@ emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber, return {std::move(I), std::move(Parent)}; } +std::pair, std::unique_ptr> +emitInfo(const VarDecl *D, const FullComment *FC, int LineNumber, + llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) { + auto I = std::make_unique(); + bool IsInAnonymousNamespace = false; + populateSymbolInfo(*I, D, FC, LineNumber, File, IsFileInRootDir, + IsInAnonymousNamespace); + if (!shouldSerializeInfo(PublicOnly, IsInAnonymousNamespace, D)) +return {}; + + I->Path = getInfoRelativePath(I->Namespace); + + PopulateTemplateParameters(I->Template, D); + + // Full and partial specializations. + if (auto *CTSD = dyn_cast(D)) { +if (!I->Template) + I->Template.emplace(); +I->Template->Specialization.emplace(); +auto &Specialization = *I->Template->Specialization; + +// What this is a specialization of. +auto SpecOf = CTSD->getSpecializedTemplateOrPartial(); +if (auto *CTD = dyn_cast(SpecOf)) + Specialization.SpecializationOf = getUSRForDecl(CTD); +else if (auto *CTPSD = + dyn_cast(SpecOf)) + Specialization.SpecializationOf = getUSRForDecl(CTPSD); + +// Parameters to the specilization. For partial specializations, get the petrhosek wrote: ```suggestion // Parameters to the specialization. For partial specializations, get the ``` https://github.com/llvm/llvm-project/pull/135457 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Handle static members and functions (PR #135457)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/135457 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV][Driver] Add riscv emulation mode to linker job of BareMetal toolchain (PR #134442)
@@ -534,8 +534,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-Bstatic"); - if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax)) -CmdArgs.push_back("--no-relax"); + if (Triple.isRISCV()) { +CmdArgs.push_back("-X"); +if (Args.hasArg(options::OPT_mno_relax)) + CmdArgs.push_back("--no-relax"); +if (const char *LDMOption = getLDMOption(TC.getTriple(), Args)) { + CmdArgs.push_back("-m"); + CmdArgs.push_back(LDMOption); +} else { + D.Diag(diag::err_target_unknown_triple) << Triple.str(); + return; +} petrhosek wrote: Can you also swap the order of the `-m` option to be the same as in the `Gnu` driver? ```suggestion if (const char *LDMOption = getLDMOption(TC.getTriple(), Args)) { CmdArgs.push_back("-m"); CmdArgs.push_back(LDMOption); } else { D.Diag(diag::err_target_unknown_triple) << Triple.str(); return; } CmdArgs.push_back("-X"); if (Args.hasArg(options::OPT_mno_relax)) CmdArgs.push_back("--no-relax"); ``` In a follow up change, I'd like to move the `-m` out of this condition since it'd be also beneficial for other targets. https://github.com/llvm/llvm-project/pull/134442 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV][Driver] Add riscv emulation mode to linker job of BareMetal toolchain (PR #134442)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/134442 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/121830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV][Driver] Add riscv emulation mode to linker job of BareMetal toolchain (PR #134442)
@@ -534,8 +534,14 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-Bstatic"); - if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax)) -CmdArgs.push_back("--no-relax"); + if (Triple.isRISCV()) { +if (Args.hasArg(options::OPT_mno_relax)) + CmdArgs.push_back("--no-relax"); +CmdArgs.push_back("-m"); +CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv" +: "elf32lriscv"); +CmdArgs.push_back("-X"); + } petrhosek wrote: This is just a nit, but I'd prefer using the same order as other drivers for consistency. ```suggestion if (Triple.isRISCV()) { CmdArgs.push_back("-X"); if (Args.hasArg(options::OPT_mno_relax)) CmdArgs.push_back("--no-relax"); CmdArgs.push_back("-m"); CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv" : "elf32lriscv"); } ``` https://github.com/llvm/llvm-project/pull/134442 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [RISCV][Driver] Add riscv emulation mode to linker job of BareMetal toolchain (PR #134442)
@@ -534,8 +534,14 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-Bstatic"); - if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax)) -CmdArgs.push_back("--no-relax"); + if (Triple.isRISCV()) { +if (Args.hasArg(options::OPT_mno_relax)) + CmdArgs.push_back("--no-relax"); +CmdArgs.push_back("-m"); +CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv" +: "elf32lriscv"); petrhosek wrote: I think it'd be cleaner to move https://github.com/llvm/llvm-project/blob/0f526498a1b0819055d1094fd9850fdbcab5b903/clang/lib/Driver/ToolChains/Gnu.cpp#L224-L292 to https://github.com/llvm/llvm-project/blob/0f526498a1b0819055d1094fd9850fdbcab5b903/clang/lib/Driver/ToolChains/CommonArgs.cpp and then use it here rather than duplicating this logic in two places. https://github.com/llvm/llvm-project/pull/134442 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Change linker job in Baremetal toolchain object accomodate GCCInstallation.(2/3) (PR #121830)
petrhosek wrote: I asked for various parts of the linker setup to be moved into a separate PR. I understand that each of those changes would cause some churn in tests, but I think that's desirable so we understand the effect of each of those changes in isolation. https://github.com/llvm/llvm-project/pull/121830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Change linker job in Baremetal toolchain object accomodate GCCInstallation.(2/3) (PR #121830)
@@ -565,26 +637,16 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, } if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { +CmdArgs.push_back("--start-group"); AddRunTimeLibs(TC, D, CmdArgs, Args); - CmdArgs.push_back("-lc"); +if (TC.isUsingLD()) + CmdArgs.push_back("-lgloss"); petrhosek wrote: I proposed the libc selection as a topic for the next LLVM libc monthly meeting on March 13. https://github.com/llvm/llvm-project/pull/121830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] release/20.x: [libc] Move __LLVM_LIBC__ define to __llvm-libc-common.h (#126877) (PR #126960)
https://github.com/petrhosek updated https://github.com/llvm/llvm-project/pull/126960 >From 87587f925442d6369a7d511426a55ad50f3141ea Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 12 Feb 2025 11:37:07 -0800 Subject: [PATCH] [libc] Move __LLVM_LIBC__ define to __llvm-libc-common.h (#126877) Relying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting __LLVM_LIBC__. Since __llvm-libc-common.h is included from all libc headers, defining __LLVM_LIBC__ there ensures that this define is available whenever any of the standard header is included. (cherry picked from commit b0d782080529cf5d422847e1f91f29bd7c62f691) --- libc/include/__llvm-libc-common.h | 2 ++ libc/include/llvm-libc-macros/features-macros.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h index b5a23c5765f4d..9112d1ebe302c 100644 --- a/libc/include/__llvm-libc-common.h +++ b/libc/include/__llvm-libc-common.h @@ -9,6 +9,8 @@ #ifndef LLVM_LIBC_COMMON_H #define LLVM_LIBC_COMMON_H +#define __LLVM_LIBC__ 1 + #ifdef __cplusplus #undef __BEGIN_C_DECLS diff --git a/libc/include/llvm-libc-macros/features-macros.h b/libc/include/llvm-libc-macros/features-macros.h index 5bc87a68fc0ba..f87ae4ad12408 100644 --- a/libc/include/llvm-libc-macros/features-macros.h +++ b/libc/include/llvm-libc-macros/features-macros.h @@ -9,6 +9,4 @@ #ifndef LLVM_LIBC_MACROS_FEATURES_MACROS_H #define LLVM_LIBC_MACROS_FEATURES_MACROS_H -#define __LLVM_LIBC__ 1 - #endif // LLVM_LIBC_MACROS_FEATURES_MACROS_H ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)
@@ -545,9 +545,27 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } - if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, - options::OPT_r)) { -CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o"))); + bool WantCRTs = + !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles); + + const char *crtbegin, *crtend; + if (WantCRTs) { +if (!Args.hasArg(options::OPT_r)) + CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o"))); +if (TC.hasValidGCCInstallation() || hasGCCToolChainAlongSideClang(D)) { + auto RuntimeLib = TC.GetRuntimeLibType(Args); + if (RuntimeLib == ToolChain::RLT_Libgcc) { +crtbegin = "crtbegin.o"; +crtend = "crtend.o"; + } else { +assert(RuntimeLib == ToolChain::RLT_CompilerRT); +crtbegin = +TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object); +crtend = +TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object); petrhosek wrote: I think a `switch` is a better fit here: ```suggestion auto RuntimeLib = TC.GetRuntimeLibType(Args); switch (TC.GetRuntimeLibType(Args)) { case ToolChain::RLT_Libgcc) { crtbegin = "crtbegin.o"; crtend = "crtend.o"; break; } case ToolChain::RLT_CompilerRT: { crtbegin = TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object); crtend = TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object); break; } ``` https://github.com/llvm/llvm-project/pull/121830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)
@@ -545,9 +545,27 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } - if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, - options::OPT_r)) { -CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o"))); + bool WantCRTs = petrhosek wrote: This is just a suggestion, but I think `NeedsCRT` would be more accurate. ```suggestion bool NeedCRT = ``` https://github.com/llvm/llvm-project/pull/121830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)
@@ -545,9 +545,27 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } - if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, - options::OPT_r)) { -CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o"))); + bool WantCRTs = + !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles); + + const char *crtbegin, *crtend; petrhosek wrote: This is probably more consistent with LLVM style: ```suggestion const char *CRTBegin, *CRTEnd; ``` https://github.com/llvm/llvm-project/pull/121830 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Add HTMLMustacheGenerator methods (PR #138061)
@@ -57,18 +57,118 @@ class MustacheTemplateFile : public Template { MustacheTemplateFile(StringRef TemplateStr) : Template(TemplateStr) {} }; +static std::unique_ptr NamespaceTemplate = nullptr; + +static std::unique_ptr RecordTemplate = nullptr; + +static Error setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) { + return Error::success(); +} + Error MustacheHTMLGenerator::generateDocs( StringRef RootDir, StringMap> Infos, const clang::doc::ClangDocContext &CDCtx) { + if (auto Err = setupTemplateFiles(CDCtx)) +return Err; + // Track which directories we already tried to create. + StringSet<> CreatedDirs; + // Collect all output by file name and create the necessary directories. + StringMap> FileToInfos; + for (const auto &Group : Infos) { +doc::Info *Info = Group.getValue().get(); + +SmallString<128> Path; +sys::path::native(RootDir, Path); +sys::path::append(Path, Info->getRelativeFilePath("")); +if (!CreatedDirs.contains(Path)) { + if (std::error_code Err = sys::fs::create_directories(Path); + Err != std::error_code()) +return createStringError(Err, "Failed to create directory '%s'.", petrhosek wrote: We don't seem to be using full sentences elsewhere. ```suggestion return createStringError(Err, "failed to create directory '%s'", ``` https://github.com/llvm/llvm-project/pull/138061 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Add HTMLMustacheGenerator methods (PR #138061)
@@ -57,18 +57,118 @@ class MustacheTemplateFile : public Template { MustacheTemplateFile(StringRef TemplateStr) : Template(TemplateStr) {} }; +static std::unique_ptr NamespaceTemplate = nullptr; + +static std::unique_ptr RecordTemplate = nullptr; + +static Error setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) { + return Error::success(); +} + Error MustacheHTMLGenerator::generateDocs( StringRef RootDir, StringMap> Infos, const clang::doc::ClangDocContext &CDCtx) { + if (auto Err = setupTemplateFiles(CDCtx)) +return Err; + // Track which directories we already tried to create. + StringSet<> CreatedDirs; + // Collect all output by file name and create the necessary directories. + StringMap> FileToInfos; + for (const auto &Group : Infos) { +doc::Info *Info = Group.getValue().get(); + +SmallString<128> Path; +sys::path::native(RootDir, Path); +sys::path::append(Path, Info->getRelativeFilePath("")); +if (!CreatedDirs.contains(Path)) { + if (std::error_code Err = sys::fs::create_directories(Path); + Err != std::error_code()) +return createStringError(Err, "Failed to create directory '%s'.", + Path.c_str()); + CreatedDirs.insert(Path); +} + +sys::path::append(Path, Info->getFileBaseName() + ".html"); +FileToInfos[Path].push_back(Info); + } + + for (const auto &Group : FileToInfos) { +std::error_code FileErr; +raw_fd_ostream InfoOS(Group.getKey(), FileErr, sys::fs::OF_None); +if (FileErr) + return createStringError(FileErr, "Error opening file '%s'", petrhosek wrote: ```suggestion return createStringError(FileErr, "error opening file '%s'", ``` https://github.com/llvm/llvm-project/pull/138061 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Update serializer for improved template handling (PR #138065)
@@ -710,11 +897,12 @@ emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc, // What this is a specialization of. auto SpecOf = CTSD->getSpecializedTemplateOrPartial(); -if (auto *CTD = dyn_cast(SpecOf)) - Specialization.SpecializationOf = getUSRForDecl(CTD); -else if (auto *CTPSD = - dyn_cast(SpecOf)) - Specialization.SpecializationOf = getUSRForDecl(CTPSD); +if (auto *SpecPtr = dyn_cast(SpecOf)) { + Specialization.SpecializationOf = getUSRForDecl(SpecPtr); +} else if (auto *SpecPtr = + dyn_cast(SpecOf)) { + Specialization.SpecializationOf = getUSRForDecl(SpecPtr); +} petrhosek wrote: LLVM style omits curly braces for single-statement bodies: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements https://github.com/llvm/llvm-project/pull/138065 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Update serializer for improved template handling (PR #138065)
@@ -710,11 +897,12 @@ emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc, // What this is a specialization of. auto SpecOf = CTSD->getSpecializedTemplateOrPartial(); -if (auto *CTD = dyn_cast(SpecOf)) - Specialization.SpecializationOf = getUSRForDecl(CTD); -else if (auto *CTPSD = - dyn_cast(SpecOf)) - Specialization.SpecializationOf = getUSRForDecl(CTPSD); +if (auto *SpecPtr = dyn_cast(SpecOf)) { + Specialization.SpecializationOf = getUSRForDecl(SpecPtr); +} else if (auto *SpecPtr = + dyn_cast(SpecOf)) { + Specialization.SpecializationOf = getUSRForDecl(SpecPtr); +} petrhosek wrote: This also applies to other edits in this PR where we use curly braces around single-statement bodies. https://github.com/llvm/llvm-project/pull/138065 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Update serializer for improved template handling (PR #138065)
@@ -362,6 +362,9 @@ struct FunctionInfo : public SymbolInfo { // specializations. SmallString<16> FullName; + // Function Prototype + SmallString<256> ProtoType; petrhosek wrote: This capitalization might imply that this is a type of proto(type), we also use "prototype" elsewhere. ```suggestion SmallString<256> Prototype; ``` https://github.com/llvm/llvm-project/pull/138065 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Implement setupTemplateValue for HTMLMustacheGenerator (PR #138064)
@@ -406,8 +406,26 @@ static json::Value extractValue(const RecordInfo &I, static Error setupTemplateValue(const ClangDocContext &CDCtx, json::Value &V, Info *I) { - return createStringError(inconvertibleErrorCode(), - "setupTemplateValue is unimplemented"); + V.getAsObject()->insert({"ProjectName", CDCtx.ProjectName}); + json::Value StylesheetArr = Array(); + auto InfoPath = I->getRelativeFilePath(""); + SmallString<128> RelativePath = computeRelativePath("", InfoPath); + for (const auto &FilePath : CDCtx.UserStylesheets) { +SmallString<128> StylesheetPath = RelativePath; +sys::path::append(StylesheetPath, sys::path::filename(FilePath)); +sys::path::native(StylesheetPath, sys::path::Style::posix); +StylesheetArr.getAsArray()->emplace_back(StylesheetPath); + } petrhosek wrote: We shouldn't be calling `sys::path::native` repeatedly inside the loop. ```suggestion SmallString<128> RelativePath = computeRelativePath("", InfoPath); sys::path::native(RelativePath, sys::path::Style::posix); for (const auto &FilePath : CDCtx.UserStylesheets) { SmallString<128> StylesheetPath = RelativePath; sys::path::append(StylesheetPath, sys::path::filename(FilePath), sys::path::Style::posix); StylesheetArr.getAsArray()->emplace_back(StylesheetPath); } ``` https://github.com/llvm/llvm-project/pull/138064 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Add helpers for Template config (PR #138062)
@@ -86,8 +87,16 @@ TEST(HTMLMustacheGeneratorTest, generateDocs) { assert(G && "Could not find HTMLMustacheGenerator"); ClangDocContext CDCtx = getClangDocContext(); - StringRef RootDir = ""; - EXPECT_THAT_ERROR(G->generateDocs(RootDir, {}, CDCtx), Succeeded()) + unittest::TempDir RootTestDirectory("generateDocsTest", /*Unique=*/true); + CDCtx.OutDirectory = RootTestDirectory.path(); + + // This seems wrong, but its unclear how else we would test this... + SmallString<128> AssetPath("../../../../../share/clang-doc"); + llvm::sys::path::native(AssetPath); + getMustacheHtmlFiles(AssetPath, CDCtx); petrhosek wrote: Could you get the path from CMake? What I have in mind is generate a `config.h` file akin to what we do in [Clang](https://github.com/llvm/llvm-project/blob/52f568dbbb61ffe26b7973b482e0e504b405a0ab/clang/CMakeLists.txt#L886-L888) and other LLVM projects and put the relevant paths there. https://github.com/llvm/llvm-project/pull/138062 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Add HTMLMustacheGenerator methods (PR #138061)
petrhosek wrote: Here's an idea that doesn't need to be addressed in this PR. We already have the YAML backend for Clang-doc which is primarily used for testing and also to allow external backends. We chose YAML because back when we started working on it, there was no JSON support in LLVM, but today I think we would have gone with JSON since it's more universally supported (e.g. in languages like Go or Python it's part of the standard library as opposed to YAML). What if we replaced the YAML backend with JSON backend? We could then use its output with the Mustache templates rather than building what is essentially an internal JSON backend inside the `HTMLMustacheGenerator`. We could do the same for Markdown as well, using a different set of Mustache templates with the output from the JSON backend. https://github.com/llvm/llvm-project/pull/138061 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Track if a type is a template or builtin (PR #138067)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/138067 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Update clang-doc tool to enable mustache templates (PR #138066)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/138066 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] Implement setupTemplateValue for HTMLMustacheGenerator (PR #138064)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/138064 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)
@@ -0,0 +1,26 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: clang-doc --output=%t --format=json --executor=standalone %s +// RUN: FileCheck %s < %t/GlobalNamespace/index.json + +static void myFunction() {} + +void noExceptFunction() noexcept {} + +inline void inlineFunction() {} + +extern void externFunction() {} + +constexpr void constexprFunction() {} + +// CHECK: "Functions": [ +// CHECK-NEXT: { +// CHECK: "IsStatic": true, +// COM:FIXME: Emit ExceptionSpecificationType +// CHECK-NOT: "ExceptionSpecifcation" : "noexcept", +// COM:FIXME: Emit inline +// CHECK-NOT: "IsInline": true, +// COM:FIXME: Emit extern +// CHECK-NOT: "IsExtern": true, +// COM:FIXME: Emit constexpr +// CHECK-NOT: "IsConstexpr": true, +// CHECK-NOT: "IsConstexpr": true, petrhosek wrote: Duplicate `CHECK-NOT` line? https://github.com/llvm/llvm-project/pull/143209 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/143209 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Modular printf option (float only) (PR #147426)
@@ -0,0 +1,41 @@ +#ifdef LIBC_COPT_PRINTF_MODULAR petrhosek wrote: This file needs the copyright header. https://github.com/llvm/llvm-project/pull/147426 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits