Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flang-rt/test/Driver/ctofortran.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
! UNSUPPORTED: offload-cuda

! RUN: split-file %s %t
! RUN: %clang -I"%include/flang" -c %t/cfile.c -o %t/cfile.o
! RUN: %flang -L"%libdir" %t/ffile.f90 %t/cfile.o -o %t/ctofortran
! RUN: %clang %isysroot -I"%include/flang" -c %t/cfile.c -o %t/cfile.o
! RUN: %flang %isysroot -L"%libdir" %t/ffile.f90 %t/cfile.o -o %t/ctofortran
! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%libdir" %t/ctofortran | FileCheck %s

!--- ffile.f90
Expand Down
2 changes: 1 addition & 1 deletion flang-rt/test/Runtime/no-cpp-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ UNSUPPORTED: system-windows
UNSUPPORTED: offload-cuda

RUN: %if system-aix %{ export OBJECT_MODE=64 %}
RUN: %cc -std=c99 %s -I%include -L"%libdir" -lflang_rt.runtime -lm \
RUN: %cc -std=c99 %s %isysroot -I%include -L"%libdir" -lflang_rt.runtime -lm \
RUN: %if system-aix %{-lpthread %}
RUN: rm a.out
*/
Expand Down
7 changes: 3 additions & 4 deletions flang-rt/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,24 @@ def shjoin(args, sep=" "):
# lit writes a '.lit_test_times.txt' file into this directory.
config.test_exec_root = config.flang_rt_binary_test_dir

# On MacOS, -isysroot is needed to build binaries.
# On MacOS, some tests need -isysroot to build binaries.
isysroot_flag = []
if config.osx_sysroot:
isysroot_flag = ["-isysroot", config.osx_sysroot]
config.substitutions.append(("%isysroot", " ".join(isysroot_flag)))

tools = [
ToolSubst(
"%flang",
command=config.flang,
extra_args=isysroot_flag,
unresolved="fatal",
),
ToolSubst(
"%clang",
command=FindTool("clang"),
extra_args=isysroot_flag,
unresolved="fatal",
),
ToolSubst("%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"),
ToolSubst("%cc", command=config.cc, unresolved="fatal"),
]
llvm_config.add_tool_substitutions(tools)

Expand Down
24 changes: 4 additions & 20 deletions flang/test/Integration/iso-fortran-binding.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// REQUIRES: clang
// UNSUPPORTED: system-windows
// RUN: split-file %s %t
// RUN: chmod +x %t/runtest.sh
// RUN: %t/runtest.sh %t %t/cppfile.cpp %flang | FileCheck %s
// RUN: rm -rf %t && mkdir %t
// RUN: %clangxx %isysroot -I%flang_include %s -o %t/a.out
// RUN: %t/a.out | FileCheck %s

//--- cppfile.cpp
extern "C" {
#include "ISO_Fortran_binding.h"
}
Expand All @@ -15,19 +15,3 @@ int main() {
}

// CHECK: PASS
// clang-format off
//--- runtest.sh
#!/bin/bash
TMPDIR=$1
CPPFILE=$2
FLANG=$3
BINDIR=`dirname $FLANG`
CPPCOMP=$BINDIR/clang++
if [ -x $CPPCOMP ]
then
$CPPCOMP $CPPFILE -o $TMPDIR/a.out
$TMPDIR/a.out # should print "PASS"
else
# No clang compiler, just pass by default
echo "PASS"
fi
9 changes: 7 additions & 2 deletions flang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@
"PATH", config.flang_llvm_tools_dir, append_path=True
)

# On MacOS, -isysroot is needed to build binaries.
# On MacOS, some tests need -isysroot to build binaries.
isysroot_flag = []
if config.osx_sysroot:
isysroot_flag = ["-isysroot", config.osx_sysroot]
config.substitutions.append(("%isysroot", " ".join(isysroot_flag)))

# Check for DEFAULT_SYSROOT, because when it is set -isysroot has no effect.
if config.default_sysroot:
Expand All @@ -133,7 +134,6 @@
ToolSubst(
"%flang",
command=FindTool("flang"),
extra_args=isysroot_flag,
unresolved="fatal",
),
ToolSubst(
Expand Down Expand Up @@ -172,6 +172,11 @@
else:
llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)

llvm_config.use_clang(required=False)

# Clang may need the include path for ISO_fortran_binding.h.
config.substitutions.append(("%flang_include", config.flang_intrinsic_modules_dir))

# Enable libpgmath testing
result = lit_config.params.get("LIBPGMATH")
if result:
Expand Down
1 change: 1 addition & 0 deletions flang/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import lit.util
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@"))
config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
config.host_triple = "@LLVM_HOST_TRIPLE@"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this been added? I don't see it being used anywhere in this PR - at least not directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used by llvm_config.use_clang(required=False). But it also has a fallback when not defined. Without e.g. the feature native is not defined. Not sure we strictly need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove this line, I'll get the following error message. We could fix clang_setup by adding a check for hasattr(self.config, "host_triple"), but I'm not sure it is better.

llvm-lit: /path/to/llvm-project/llvm/utils/lit/lit/TestingConfig.py:157: fatal: unable to parse config file '/path/to/llvm-project/flang/test/lit.cfg.py', traceback: Traceback (most recent call last):
  File "/path/to/llvm-project/llvm/utils/lit/lit/TestingConfig.py", line 145, in load_from_path
    exec(compile(data, path, "exec"), cfg_globals, None)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/llvm-project/flang/test/lit.cfg.py", line 175, in <module>
    llvm_config.use_clang(required=False)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/path/to/llvm-project/llvm/utils/lit/lit/llvm/config.py", line 689, in use_clang
    self.clang_setup(additional_tool_dirs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/llvm-project/llvm/utils/lit/lit/llvm/config.py", line 638, in clang_setup
    if self.config.host_triple and self.config.host_triple != "@LLVM_HOST_TRIPLE@":
       ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestingConfig' object has no attribute 'host_triple'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen hasattr(self.config, "host_triple") at other places, seems that some change did not consider it may not be set.

Since we would want clang to know whether it is cross-compiling, I would keep config.host_triple = .. as-is.

config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.llvm_target_triple_env = "@LLVM_TARGET_TRIPLE_ENV@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
Expand Down