LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-15-2014, 08:09 PM   #1
slackj
LQ Newbie
 
Registered: Oct 2012
Location: Brazil
Distribution: Slackware
Posts: 9

Rep: Reputation: 0
Post Multilib gfortran generates 64-bit output, only (14.1)


I was having trouble compiling 32-bit versions of blas (which I'd use
for atlas, then lapack) under Slackware 14.1 in a multilib system. It failed every
time.

After investigating into the issue, I realized gfortran was producing
64-bit output, even after the . /etc/profile.d/32dev.sh command. This
does not happen with gcc ou g++, only with gfortran.

For instance, you take any .c file (say, file1.c) and any .f file
(say, file2.f), and compile them with
gcc -c -o test1.o file1.c
gfortran -c -o test2.o file2.f
Issuing a file command on both will show test1.o will be 32-bit and
test2.o will be 64-bit.

I do not know if this has a necessary relation with the problem, but I
did check executables for gcc and g++ are found in /usr/bin/32/, but
one will not find any gfortran executable file over there.
 
Old 01-16-2014, 04:05 AM   #2
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

/usr/bin/32/gcc is a shell wrapper that pass -m32 to the compiler. Since /usr/bin/g++ is a symlink to /usr/bin/32/gcc, you simply have to create a gfortran symlink to gcc in /usr/bin/32 to fix this issue, I guess :

Code:
$ su
$ cd /usr/bin/32
$ ln -s gcc gfortran

Code:
$ cd /tmp
$ echo -e "program HelloWorld\n write(*,*) \"Hello World\"\nend program HelloWorld" > HelloWorld.f90

$ gfortran HelloWorld.f90 -o HelloWorld.64bit
$ file HelloWorld.64bit 
HelloWorld.64bit: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped


$ . /etc/profile.d/32dev.sh
$ gfortran HelloWorld.f90 -o HelloWorld.32bit
$ file HelloWorld.32bit 
HelloWorld.32bit: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
Hope this helps.

Cheers

--
SeB
 
Old 01-16-2014, 05:06 AM   #3
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116Reputation: 8116
I have replied to the OP in an email (he emailed me as well as posting here) and gave a similar workaround instruction (basically, just add "-m32" to the commandline).
I have however also updated the compat32-tools with support for fortran (a fortran wrapper and some extra lines in the 32dev.* profile scripts). I want to test this before releasing it, and that must wait until tonight when I get home.

Eric
 
Old 01-16-2014, 08:20 AM   #4
slackj
LQ Newbie
 
Registered: Oct 2012
Location: Brazil
Distribution: Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks to both of you. I will do as instructed right now and post the results.

PS: since I thanked you here, Alien, I will not do so through e-mail, since I assume you already get a lot of e-mail every day.

This is the reply:

Quote:
Well, the basic issue is that I never provided a gfortran wrapper for 32-bit builds, like I did with the gcc wrapper in /usr/bin/32

It is easy to add though, and I will.

In the mean time, try the difference in output architecture when you add the "-m32" flag manually. Last time I used fortran was at university - and that was more than 30 years ago - so here is my test:

$ cat <<EOT > hellotest.f
program hello
print *, "Hello World!"
end program hello
EOT

$ g95 -o hello hellotest.f
$ file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
$ # ./hello
Hello World!
$ g95 -m32 -o hello32 hellotest.f
$ file hello32
hello32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
$ # ./hello32
Hello World!

Writing a wrapper for gfortran analogous to /usr/bin/32/gcc is not hard.

Alternatively, I think you could also achieve the desired effect by defining additional variables in your environment:

export FC='gfortran -m32'
export F77='gfortran -m32'

Cheers, Eric

Last edited by slackj; 01-16-2014 at 08:27 AM.
 
Old 01-16-2014, 11:11 AM   #5
slackj
LQ Newbie
 
Registered: Oct 2012
Location: Brazil
Distribution: Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by slackj View Post
Thanks to both of you. I will do as instructed right now and post the results.
I copied /usr/bin/32/g++ to /usr/bin/32/gfortran. This seems to fix the fortran compilation problem.

After it was done, 32-bit output was being produced (after . /etc/profile.d/32dev.sh) and I could get blas to compile with a Slackbuild, but not atlas. Apparently, there are a few patches for further versions of atlas (read after 3.8.3, which is linked at Slackbuilds website) around that may help. All in all, I believe fortran compilation is fixed. Since I failed to get a log for the build, I'll post later if I still need help.

Thanks for the help, again.
 
  


Reply

Tags
multilib, slackware


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Cannot install fpc 32 bit on 64 bit multilib slackbuild. george-lappies Slackware 8 05-26-2011 10:37 AM
[SOLVED] ati driver 32-bit compatibility for Slackware 64-bit multilib? vik Slackware 25 02-16-2010 08:06 PM
[SOLVED] CLFS 64 bit multilib and pure 64 bit pacthes wanted Openumerix Linux From Scratch 1 11-16-2009 01:23 AM
sql output generates on a os text file ! shipon_97 Linux - General 0 01-14-2009 06:46 AM
MPlayer only generates png, no x output delling81 Linux - Software 1 10-03-2003 02:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration