Fwd: Building FLANG on Ubuntu

145 views
Skip to first unread message

Amrita H S

unread,
Mar 3, 2017, 9:47:05 AM3/3/17
to flan...@googlegroups.com

Hello,

 

I am trying to build FLANG. I followed these steps referring the README.txt in FLANG github sources(https://github.com/llvm-flang/flang) .

 

1.       I cloned the latest llvm sources:

git clone https://github.com/llvm-mirror/llvm.git

 

2.       Download the flang source code with in llvm tree:

           cd llvm/tools

           git clone https://github.com/llvm-flang/flang.git

 

3.       Compile LLVM and flang together:

           mkdir build

           cd build

           cmake ../.. -DCMAKE_INSTALL_PREFIX=/usr

 

This throws some warnings when generating configuration files for FLANG. Some of them like:

 

  CMake Warning (dev) in tools/flang/lib/AST/CMakeLists.txt:

  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link

  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the

  cmake_policy command to set the policy and suppress this warning.

 

  Target "flangAST" has an INTERFACE_LINK_LIBRARIES property.  This should be

  preferred as the source of the link interface for this library but because

  CMP0022 is not set CMake is ignoring the property and using the link

  implementation as the link interface instead.

 

  INTERFACE_LINK_LIBRARIES:

    LLVMSupport;flangBasic

 

  Link implementation:

    flangBasic

  This warning is for project developers.  Use -Wno-dev to suppress it.

 

  CMake Warning (dev) at tools/flang/tools/driver/CMakeLists.txt:28 (add_dependencies):

  Policy CMP0046 is not set: Error on non-existent dependency in

  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.

  Use the cmake_policy command to set the policy and suppress this warning.

 

  The dependency target "flang-headers" of target "flang" does not exist.

  This warning is for project developers.  Use -Wno-dev to suppress it.

 

4.       Since build files were generated, I tried make. But I got some compile time errors when building “obj.flang-tblgen”:

             [ 88%] Building CXX object tools/flang/utils/TableGen/CMakeFiles/obj.flang-tblgen.dir/FlangASTNodesEmitter.cpp.o

             $LLVM_ROOT/llvm/tools/flang/utils/TableGen/FlangASTNodesEmitter.cpp: In member function std::string {anonymous}::FlangASTNodesEmitter::     baseName(llvm::Record&):

             $LLVM_ROOT/llvm/tools/flang/utils/TableGen/FlangASTNodesEmitter.cpp:50:24: error: no match for operator+ (operand types are llvm::StringRef and const string {aka const std::basic_string<char>})

              return R.getName() + BaseSuffix;

 

      I tried to fix this error by changing the line  return R.getName() + BaseSuffix; to return R.getName().str() + BaseSuffix; in file $LLVM_ROOT/llvm/tools/flang/utils/TableGen/FlangASTNodesEmitter.cpp


5.       After this when I tried running make again, I got this error:

               [ 88%] Building CXX object tools/flang/utils/TableGen/CMakeFiles/obj.flang-tblgen.dir/FlangDiagnosticsEmitter.cpp.o

               $LLVM_ROOT/llvm/tools/flang/utils/TableGen/FlangDiagnosticsEmitter.cpp: In function llvm::SMRange findSuperClassRange(const llvm::Record*, llvm::StringRef):

               $LLVM_ROOT/llvm/tools/flang/utils/TableGen/FlangDiagnosticsEmitter.cpp:154:50: error: conversion from llvm::ArrayRef<std::pair<llvm::Record*, llvm::SMRange> > to non-scalar type llvm::ArrayRef<llvm::Record*>requested

                ArrayRef<Record *> Supers = R->getSuperClasses();

                $LLVM_ROOT/llvm/tools/flang/utils/TableGen/FlangDiagnosticsEmitter.cpp:158:17: error: const class llvm::Record has no member named getSuperClassRanges

                return R->getSuperClassRanges()[i];

 

     I searched the header file $LLVM_ROOT/llvm/include/llvm/TableGen/Record.h for definition of getSuperClassRanges, but it is not defined there.

 

 

I am trying to build on Ubuntu_16.10 installed on x86_64 machine. cmake version 3.7.2 and gcc version 6.2 is being used to build flang.

 

Can anyone please help me to identify what could be going wrong or am I missing something?

 

 

Regards And Thanks,


Amrita H S

John Leidel

unread,
Mar 3, 2017, 10:28:41 AM3/3/17
to Amrita H S, flang-dev
Amrita, the Flang source is rather stale and will not likely build against the current LLVM trunk.  The project hasn't been under active development using this source base for almost a year.   This is, however, an ongoing effort to build a more robust Fortran frontend for LLVM.  I permit others on this mailing list to chime in.  

cheers
john

--
You received this message because you are subscribed to the Google Groups "flang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flang-dev+unsubscribe@googlegroups.com.
To post to this group, send email to flan...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flang-dev/CAMOtZ-9gPqFbZCBYo_oNuvEiKvZsGncD7B92L6knZh8s62ypNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Amrita H S

unread,
Mar 4, 2017, 7:10:47 AM3/4/17
to flang-dev, hsam...@gmail.com
Hi John,

Thanks for the quick response. Is there a way to get a working FLANG build, irrespective of LLVM version?. Also can you please let me know if there is a different or a more stable version of FLANG available anywhere else?

Regards,
Amrita
To unsubscribe from this group and stop receiving emails from it, send an email to flang-dev+...@googlegroups.com.

John Leidel

unread,
Mar 4, 2017, 8:47:24 AM3/4/17
to Amrita H S, flang-dev
Amrita, the simple answer is 'no' in both cases.  The Flang frontend source is inherently tied to the library interfaces of the LLVM core.  There is also no other open source Fortran frontend as of yet.  

The long answer is you can try cloning a rather old version of the LLVM core and attempting to build from there.  The latest git hash I have building against Flang is: 
78175c073a86468070c38fb147979527787a6ac8

Keep in mind, even when you have this built, Flang will be very limited in its functionality.  Do not be surprised if its rather unstable.  


To unsubscribe from this group and stop receiving emails from it, send an email to flang-dev+unsubscribe@googlegroups.com.

To post to this group, send email to flan...@googlegroups.com.

Amrita H S

unread,
Mar 6, 2017, 4:50:21 AM3/6/17
to flang-dev, hsam...@gmail.com
Thanks John. I will try building against older version of LLVM core.

Regards,
Amrita H S

Amrita H S

unread,
Mar 10, 2017, 4:06:11 AM3/10/17
to flang-dev, hsam...@gmail.com
Hi John,

I am able to build FLANG against the older version of LLVM suggested by you. There are no build time issues. But the generated FLANG compiler fails to compile even a simple Hello World Fortarn program. I have installed the flangrt run time library as well. It is available in the location /usr/lib/liblibflang.a.

hello.f( fortran f77 program):

      PROGRAM HELLO
*     The PRINT statement is like WRITE,
*     but prints to the standard output unit
        PRINT '(A)', 'Hello, world'
        STOP
      END

 /usr/bin/flang -c -f77 hello.f

flang: $LLVM_ROOT/llvm/lib/IR/Instructions.cpp:237: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::Arr
ayRef<llvm::Value*>, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams
())) && "Calling a function with bad signature!"' failed.
#0 0x1da0a1e llvm::sys::PrintStackTrace(llvm::raw_ostream&) /wsp4/amrita/flang/flang_wrking/llvm/lib/Support/Unix/Signals.inc:405:0
#1 0x1da0d33 PrintStackTraceSignalHandler(void*) /wsp4/amrita/flang/flang_wrking/llvm/lib/Support/Unix/Signals.inc:463:0
#2 0x1d9f5a1 llvm::sys::RunSignalHandlers() /wsp4/amrita/flang/flang_wrking/llvm/lib/Support/Signals.cpp:34:0
#3 0x1d9f9f9 SignalHandler(int) /wsp4/amrita/flang/flang_wrking/llvm/lib/Support/Unix/Signals.inc:211:0
#4 0x7f2f57c92340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#5 0x7f2f56eabcc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#6 0x7f2f56eaf0d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#7 0x7f2f56ea4b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#8 0x7f2f56ea4c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#9 0x1c74148 llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) $LLVM_ROOT/llvm/lib/IR/Instructions.cpp:239:0
#10 0x4de7dd llvm::CallInst::CallInst(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::Instruction*) $LLVM_ROOT/llvm/include/llvm/IR/Instructions.h:1712:0
.
.
.
.
#30 0x408667 main $LLVM_ROOT/llvm/tools/flang/tools/driver/Main.cpp:516:0
#31 0x7f2f56e96ec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#32 0x406bc9 _start (/usr/bin/flang-3.8+0x406bc9)
Stack dump:
0.      Program arguments: /usr/bin/flang -c -f77 hello.f
1.      <eof> parser at end of file
Aborted (core dumped)


Is this an expected behavior? Or am I missing something in my execution environment? 

Thanks And Regards,
Amrita H S

John Leidel

unread,
Mar 10, 2017, 7:45:15 AM3/10/17
to Amrita H S, flang-dev
Amrita, this is probably expected.  The code is stale and very volatile.  As I said before, don't expect to get very far in terms of compiling apps.  

To unsubscribe from this group and stop receiving emails from it, send an email to flang-dev+unsubscribe@googlegroups.com.

To post to this group, send email to flan...@googlegroups.com.

Hal Finkel

unread,
Mar 10, 2017, 10:48:24 AM3/10/17
to John Leidel, Amrita H S, flang-dev

I don't believe there's working I/O support. Computational kernels only.

 -Hal

-- You received this message because you are subscribed to the Google Groups "flang-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to flang-dev+...@googlegroups.com. To post to this group, send email to flan...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/flang-dev/CAC6GRO_UzsNwSwR-oxxBhxvut0hEj0j%3D2sUzmb8ofodirOhuuQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory
Reply all
Reply to author
Forward
0 new messages