DEC Fortran Compiler? - fortran

I've been provided with a very large bank of code which I need to be able to adjust, compile, and run. After some fiddling and attempts, I've deduced that the code was written with DEC standards. gfortran (version 5.4.0, running on Linux Mint / Ubuntu) does not seem able to compile it smoothly, and the -fdec command line option does not appear to be recognized. I started trying to update the code (replacing ACCEPT with READ, etc) but the task is rather daunting - especially since every step is preceded by 30 minutes of research to find the fix.
The provider of said code used PGF77. As far as I can tell, this is not a compiler I can get for free. Are there other, free compilers that can do a comparable job? Alternatively, can I get gfortran -fdec to work somehow?

gfortran version 7 or later supports -fdec option. https://gcc.gnu.org/gcc-7/
option 1 - GNU gfortran
GNU compiler collection as of version 7 supports (released around 2018) the "-fdec" option. So go get gfortran from GCC version 7 or later or most recent. https://gcc.gnu.org/gcc-7/
option 2 - Intel ifort
Also an option but more of a hassle is to get the Intel compiler ifort which has supported the DEC extensions to fortran for many years. Intel's compiler is more of a hassle because of it is proprietary and costs money (hundreds of $ or more) and requires managing licenses.

Related

Disabling __tls_get_addr_opt for PPC

I develop software for an embedded device using the PowerPC architecture. Recently we got a new firmware upgrade and the manufacturer has provided a toolchain which is incapable of building runnable binaries.
Except for a few exceptions, where I've completely statically compiled the binary, the OS gives me following error:
isobuslog.bin: /lib/ld.so.1: version `GLIBC_2.22' not found (required by isobuslog.bin)
I've been up and down a multitude of mailing lists and threads all day, looking for a solution to this.
I finally read a post where following command was entered: powerpc-linux-gnu-readelf -Ws app/bin/isobuslog.bin | grep GLIBC_2.22
The output is as follows:
142: 00000000 0 FUNC GLOBAL DEFAULT UND __tls_get_addr_opt#GLIBC_2.22 (14)
Looking further in to the matter, it seems this is a thread-local storage optimisation routine which became available w/ GLIBC v2.22. Both the SDK I was provided and the SDK I installed myself both have GLIBC version higher than 2.22 and at least G++ 6.3 (6.3 provided by OEM, 9.2.1 installed locally on my machine) - so there's no way around this, unless I use the previous VM provided, which is based on an old Debian using GCC 4.6 - this is not an option, as we require C++11 and higher, without the use of Boost.
I've tried searching around some more, and have found these two linker flags which don't seem to work, causing the linker to exit with an error code, saying it couldn't recognise the flags provided.
--no-tls-optimize
--no-tls-get-addr-optimize
Is there a way to disable __tls_get_addr_opt so that my applications will build, or is there a way around this issue (except going back to ancient times)?
I've finally figured it out.
The trick is to tell G++ to pass the parameters to the linker.
This was achieved by adding the aforementioned switches to the comma-separated list like so:
-Wl,-rpath-link,${DEPS_DIR}/powerpc-linux-gnu/lib,--no-tls-optimize,--no-tls-get-addr-optimize

Fortran compile error on different machine

I'm working with a very large piece of mortran code. I'm trying to compile it on my own machine, and the mortran part goes ok, but the fortran compile fails.
On both machines I'm using gfortran with the same flags (-fPIC).
Machine 1:
Linux [omitted] 2.6.18-194.3.1.el5 #1 SMP Fri May 7 01:43:09 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux with gfortran 4.1.2 (Working - very old kernel)
Machine 2:
Linux [omitted] 4.4.0-79-generic #100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux with gfortran 5.4.0 (Not working)
The error (most of the time) I'm getting is:
Error: Invalid character in name at (1)
ExIN=$ExDEF
1
There's also a few errors about var has no implicit type.
I don't have much experience with fortran, but I'd expect compilers to be consistent across platforms, especially since this was developed with the intent of being cross-platform.
Edit - it looks like I had a different version of the mortran compiler. I'm going to try to find the old version and see if that does it. They are mortran macros and they are supposed to expand to something.
Dollar is not a valid character of the Fortran character set.
Some compilers allow it by extension. To allow it in GNU Fortran, but not as first character and only if the target system supports it, use
-fdollar-ok
See https://gcc.gnu.org/onlinedocs/gfortran/Naming-conventions.html
Looks like you are out of luck with this compiler.
You may try g77 with the same option, see https://gcc.gnu.org/onlinedocs/gcc-3.4.5/g77/Dollar-Signs.html
The old gfortran 4.8.1 also does not speak about the initial letter restriction
-fdollar-ok
Allow `$' as a valid character in a symbol name.

How to install a simple Intel C/C++ compiler on a 64-bit Ubuntu system?

I need to compile c/c++ code, by running a build.sh file.
The instruction on the program (that i want to run) says it needs to be compiled by a Intel's compiler1.
After searching on the net I came across information on what to do.
Some people said that we must install first a 32-bit libraries:
https://help.ubuntu.com/community/InstallingCompilers
Others said that we must, first of any installation, change some things:
http://software.intel.com/en-us/articles/using-intel-compilers-for-linux-with-ubuntu
In the other hand, Intel's page show many suites:
http://software.intel.com/en-us/c-compilers
while the only thing that I want is simply Intel's C/C++ compiler.
Can somebody be so gentle to give me the directions on how to install a Intel's compiler on a 64-bit Ubuntu system?
Footnote 1 / Editor's note: other x86 compilers including GCC and clang (and MSVC on Windows), support Intel's SSE/AVX intrinsic functions, but Intel's compiler comes with some libraries such as SVML (e.g. SIMD sin and exp) and MKL which some code might need. Other compilers can be used with SVML if you have it installed separately.
In short, it's worth trying with other compilers, especially if you understand why something says it needs to be compiled by ICC, if getting ICC would be inconvenient. But you might (or might not) be missing out on performance for packages that detect what's available instead of just erroring.
for non commercial use you can download it from Intel
EDIT:
the IntelĀ® System Studio 2016 includes a c++ compiler.
I've tried the 32-bit version of it, the non-commecial one. I don't think it differ from the 32-bit on basic stuff related to installation. Open this and go to compilers and libraries section and you will see the C/C++ compiler. After download it read the files in doc folder; it includes how to install/use/get a key to compiler etc.
You need to install gcc compiler through apt-get install gcc
Look on example here: Install GCC

How can I write cross-platform c++ programs on my mac?

My university professor has given a requirement for us in his c++ class: We must write our programs using the gnu C++ compiler (GCC). I understand that after installing xcode, I get an apple version of gcc. However, this is not fully cross compatible as I understand. So I have tried to install the gnu gcc compiler by using mac ports, but I have been unsuccessful. After doing:
port install gcc47
When I go to the terminal and run:
gcc47 -v
I get "command not found"
When I run:
gcc -v
I get:
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
Showing that I am still using apple's version. The part I am not understanding is:
How do I install gcc (the gnu version, not apple's version)
How do I use it with an ide, such as eclipse?
The version of GCC you use (Apple or gnu native) should be irrelevant for you to proceed.
Writing portable C++ has nothing to do with the compiler--outside of ensuring your compiler does it's best to adhere to the C++ standard. Luckily enough, GCC is one of the best C++ compilers out there.
You're not looking to do cross-platform C++ per-se, because true portable C++ is somewhat of a pain to write given the various state of C++ compilers for various systems (for example the CC on VAX/VMS doesn't support templates...). I suspect what you want to do is ensure the code you write on your mac, can be compiled by your prof. As long as GCC can handle it on your mac, it should be fine.
So to your specific questions:
Your first question is unnecessary, as you can use apple's supplied g++ to compile your code.
For your second question, I would highly recommend against using an IDE while trying to learn. IDE's offer some really great time saving features, but they hide some important aspects, that I believe are worth struggling with early in your learning process, and which will help strengthen your C++ skills. And while things have certainly have gotten better, some IDE's were notorious for creating non-portable C++ (ie using void main()).
If you are still set on using Eclipse, or XCode, since it doesn't matter which GCC installation you use, the default setup should work just fine.
I've run into troubles installing gcc47 via ports in the past, but gcc46 went as expected. You may also want to install gcc_select.
From there, you can use gcc_select, or specify the path explicitly in Eclipse's toolchain editor.
Other notes:
If you don't need C++11 features, then Apple's GCC 4.2.1 should work fine. Perhaps you can detail why you can't use it. Basically, Apple's added some extensions to the toolchain in some cases (marked APPLE_ONLY), and you have good control of what options are enabled/disabled.
Recent versions of Clang which ship with Xcode handle C++ well (including some support for C++11). There are some advanced things in GCC that I miss when using Clang, but Clang's current C++ support is really quite good.

C++ frontend only compiler (convert C++ to C)

I'm currently managing some C++ code that runs on multiple platforms from a single source tree (Win32, Linux, Verifone CC terminals, MBED and even the Nintendo GBA/DS). However I need to build an app targetted at an embedded platform for which there is no C++ compiler (C only). I remmber that many of the early C++ compilers were only front-ends stitting on existing C compilers (Glockenspiel for example used MSC). Are there any such 'frontend' C++ compilers in use today that will generate C code.
Tools Platform
----------- ------------
______Visual C++ _____ WIN32
/
/_______MBED (ARM)_______MBED (ARM dev board).
/
/_________GCC (x86)________Linux
/
Source____/___________GCC (ARM)________GBA/DS
\
\__________SDA______________Verifone Verix CC Terminals
\
\________ARM SDT__________Verifine VerixV CC terminals
\
\______????_____________Renases M8/16/32.
\
\____????_____________Z8 family.
The last two platforms I have good C compilers for but no C++.
As you can see I'm supporting a large variety of platforms and I share a large body of library code (and some app code).
If you use LLVM, llvm-g++ will compile your C++ code to LLVM bitcode, and llc has a backend which converts bitcode to C.
You could write commands like this:
llvm-g++ -emit-llvm -c foo.cpp -o foo.o
llc -march=c <foo.o >foo.c
Comeau C++ does this.
Can't help with the Z8, but the Renesas M16C/M32C family has GCC these days - see http://www.kpitgnutools.com/ for prebuilt cross toolchain hosted on Windows. Haven't used it myself yet but may be a better option than a 3rd party C++ frontend, especially as your code already targets GCC on other platforms.
Comeau C++ generates C as its output, and they seem to be quite happy to port it to work with different back-end compilers, though I'm not sure about the exact pricing for that.
If you want a bit more of a "roll your own" approach, you could buy a license to the EDG C++ compiler. It's normally used as a front-end (e.g. by Comeau and Intel) but I believe as it's shipped, it includes a code generator that produces C as its output. Its licensing is oriented more toward compiler vendors, though, so a license gives you a lot of rights, but is pretty expensive.
Out of date, but maybe you want to try cfront?
I'll leave this for information - cfront doesn't have exception support.
Of what I have understood, the c++ support in gcc for r8c/m16c/r32c isn't quite mature and good enough for production code. But for r8c/m16c/m32c/r32c there is at least one compiler supporting embedded C++ and that is IAR, I think Tasking also supports embedded C++ on m16c.
Notice that the valid solution is for llvm 1.3
llvm last release was 6.0.0 so it would'nt work at all.
(I post this because i've try the solution of this post but it doesn't work anymore) (Maybe i've done something bad)
In my tests llc do not accept anymore the -march=c option.
And going back to the 1.3 isn't possible for me yet.
So try to take care about the version.