flang-compiler / clang Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
//===----------------------------------------------------------------------===// // C Language Family Front-end //===----------------------------------------------------------------------===// Welcome to Clang. This is a compiler front-end for the C family of languages (C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM compiler infrastructure project. Unlike many other compiler frontends, Clang is useful for a number of things beyond just compiling code: we intend for Clang to be host to a number of different source-level tools. One example of this is the Clang Static Analyzer. If you're interested in more (including how to build Clang) it is best to read the relevant web sites. Here are some pointers: Information on Clang: http://clang.llvm.org/ Building and using Clang: http://clang.llvm.org/get_started.html Clang Static Analyzer: http://clang-analyzer.llvm.org/ Information on the LLVM project: http://llvm.org/ If you have questions or comments about Clang, a great place to discuss them is on the Clang development mailing list: http://lists.llvm.org/mailman/listinfo/cfe-dev If you find a bug in Clang, please file it in the LLVM bug tracker: http://llvm.org/bugs/
I know that -ffixed-line-length-132 is the gfortran's equivalent of -Mextend, unfortunately, due to gfortran popularity, -ffixed-line-length-132 can be frequently found throughout the codebase in wild. Flang ignores that option which leads to compilation errors whenever lines are too long in fixed-form code:
$ flang -c sgemm_reference.f -o sgemm_reference_mp.o -fPIC -DPIC -ffixed-line-length-132 -fopenmp -O3
clang-4.0: warning: argument unused during compilation: '-ffixed-line-length-132' [-Wunused-command-line-argument]
F90-S-0023-Syntax error - unbalanced parentheses (sgemm_reference.f: 188)
F90-S-0310-Adjustable array can not have automatic bounds specifiers - a (sgemm_reference.f)
F90-S-0050-Assumed size array, a, is not a dummy argument (sgemm_reference.f)
F90-S-0310-Adjustable array can not have automatic bounds specifiers - b (sgemm_reference.f)
F90-S-0050-Assumed size array, b, is not a dummy argument (sgemm_reference.f)
F90-S-0310-Adjustable array can not have automatic bounds specifiers - c (sgemm_reference.f)
F90-S-0050-Assumed size array, c, is not a dummy argument (sgemm_reference.f)
0 inform, 0 warnings, 7 severes, 0 fatal for MAIN
This is the more general issue on how much Flang should be able to act as a drop-in replacement for gfortran and therefore accept its command-line syntax.
The following flags have the same description as their positive versions which seems incorrect.
-fno-default-integer-8
-fno-default-real-8
-Mnocache_align
-Mnodaz
note: pgf95 has the same behavior
execution listing :
pointer_problem.txt
the script (with extrension .txt added):
f90_pointer_stride_int.sh.txt
the stride in the pointer seems to be ignored
the execution listing shows 3 compilers, flang, pgf95 , and gfortran
(the test also runs successfully with ifort)
test run on linux system, Ubuntu 14.04
In Clang::ConstructJob:
CmdArgs.push_back("-O1");
Shouldn't do that to make sure debugging experience is good. Let the user choose the opt level.
pawosm-arm commented on Sep 21, 2016
This is required by software packages that use autoconf's 'configure' script to generate makefiles. As it turns out, for some of them (e.g. openmpi) 'configure' script literally adds linker options to the command line not prefixing them with '-Wl,'. This only happens when flang is discovered by 'configure' as a frontend driver. Following options were frequently encountered (AFAIR, with singe or double dash):
--whole-archive, --no-whole-archive, --rpath (with all instances of its allowed syntax), -soname.
As a workaround, --disable-shared --enable-static (usually accompanied with setting ENV variables having -fPIC -DPIC as compiler flags) can be passed to configure. This isn't a permanent solution though, the best option would be to accept these flags and pass them to the linker as they are.
@ppenzin
ppenzin commented on Sep 21, 2016
Would other Fortran compilers accept those options?
AFAIR there is check for compiler that sets some variable to prepend -Wl, (or whatever is appropriate for particular compiler) to linker flags. If compiler is not recognized that prefix stays blank, therefore it would try to pass linker flags directly.
@pawosm-arm
pawosm-arm commented on Sep 21, 2016
They would not (I tried gfortran and some other, commercial) and the least intrusive solution needs to be found. Any solution that would require the users to update their autotools will be likely rejected by the wider audience.
@ppenzin
ppenzin commented on Sep 21, 2016
Any new compiler will have to be added to autotools at some point. For now we can probably provide a way to patch makefiles or configure scripts.
A commit removing these two files is recommended:
test/Driver/fortran.f95
test/Driver/gfortran.f90
These two are failing on 'make check-clang' in presence on Flang commits.
Testing Time: 201.43s
Failing Tests (3):
Clang :: Driver/fortran.f95
Clang :: Driver/gfortran.f90
Clang :: Driver/nozlibcompress.c
Expected Passes : 9593
Expected Failures : 16
Unsupported Tests : 29
Unexpected Failures: 3
This is required in order to build software packages that use cmake. Whenever cmake is started with -DCMAKE_BUILD_TYPE=Debug or RelWithDebInfo it adds -gopt to flang command line. According to cmake scripts it adds such option as it encounters PGI compiler.
Looks like this flag (despite its disputable usability) is pretty popular across different Fortran workloads.
Following options:
-def __x86_64 -def __x86_64__ -def __amd_64__amd64__ -def __k8 -def __k8__
are always passed to flang1 on every architecture, e.g. on ARM's AArch64, e.g.:
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: flang/bin
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/aarch64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
flang1 demo.f90 -opt 0 -terse 1 -inform warn -nohpf -nostatic -y 129 2 -inform warn -x 19 0x400000 -quad -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -tp px -x 57 0xfb0000 -x 58 0x78031040 -x 47 0x08 -x 48 4608 -x 49 0x100 -stdinc flang/bin/../include:/usr/local/include:flang/lib/clang/4.0.1/include:/usr/include/aarch64-linux-gnu:/include:/usr/include -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __LP64__ -def __x86_64 -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def __SIZE_TYPE__=unsigned long int -def __PTRDIFF_TYPE__=long int -def __THROW= -def __extension__= -def __amd_64__amd64__ -def __k8 -def __k8__ -def __PGLLVM__ -freeform -vect 48 -y 54 1 -x 70 0x40000000 -y 163 0xc0000000 -x 189 0x10 -stbfile /tmp/demo-e55fd6.stb -modexport /tmp/demo-e55fd6.cmod -modindex /tmp/demo-e55fd6.cmdx -output /tmp/demo-e55fd6.ilm
Following line:
LowerCmdArgs.push_back("-x"); LowerCmdArgs.push_back("120"); LowerCmdArgs.push_back("0x1000"); // debug lite
Seems a strange thing to do instead of just passing a separate option for whatever profiling one need to do. Is it deliberate or done by mistake?
CC1Args vs F901Args
Linux.h:
AddFlangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
Linux.cpp:
void Linux::AddFlangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &F901Args) const
The -fsyntax-only option is very popular for testing clang. When applied to debug mode build of Flang it causes assertion fail:
tools/clang/lib/Frontend/FrontendAction.cpp:265: bool clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, const clang::FrontendInputFile&): Assertion `hasIRSupport() && "This action does not have IR file support!"' failed.
Does not occur with Release mode builds of Flang.
pgf90libs: tools/clang/include/clang/Driver/Options.td
pgf901: tools/clang/include/clang/Driver/ToolChain.h (in comment)
F901Args: tools/clang/lib/Driver/ToolChains.cpp, tools/clang/lib/Driver/ToolChains.h, tools/clang/include/clang/Driver/ToolChain.h
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.