You are not logged in.

#1 2012-12-21 01:55:48

SysGhost
Member
From: Stockholm
Registered: 2012-11-09
Posts: 62

makepkg ignores CC and CXX variables. Cannot compile 32 bit binaries.

EDIT: Changed subject line to reflect the current problem. See post further down.

Greetings.
I have stumbled upon a problem that I need helt with. My system doesn't behave as I want it to, and I have gotten myself intio a wall here. I don't know where to go from here.
The problem is, as the Subject line suggests, a weird behaviour with yaourt (AUR), lib32 packages and the result ELFCLASS.

Details:

Installing any lib32 sourcecode package (such as lib32-sfml-git) results in a ELFCLASS64 libraries in the /usr/lib32 folder.
At first, I thought the error was with the package files themselves, but a friend of mine cannot reproduce the result and end up with the expected and working oucome.

Here's an example:

# yaourt lib32-sfml-git
*snip*: Lots of expected output from yaourt/AUR. No errors or warnings.

# file /usr/lib32/libsfml-system.so.2.0
/usr/lib32/libsfml-system.so.2.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x7948c978199f5b329bd614c6f51ddcf7bbea8577, stried

Trying to run a 32 bit program that depends on the file above:

# ./Harvest
./Harvest: error while loading shared libraries: libsfml-system.so.2: wrong ELF class: ELFCLASS64

At first I suspected it simply tried to load it from the wrong path, so I checked:

# ls /usr/lib/libsfml*
ls: cannot access /usr/lib/libsfml*: No such file or directory

# yaourt -R lib32-sfml-git
*snip*: Normal output for a AUR package uninstallation. No errors, No warnings.

# ./Harvest
./Harvest: error while loading shared libraries: libsfml-system.so.2: cannot open shared object file: No such file or directory

I also get the same result with pretty much any lib32 package that downloads source code and compiles locally.
Precompiled packages works flawlessly, of course.

Next thing I tried to check for, was if the PKGFILES in question had proper make commands, and yes, they provite the expected '-m32' option.

Next after this, was testing a small 'hello_world' program.
It compiles just fine in both 32 and 64 bit mode, resulting in both ELFCLASS32 and ELFCLASS64, depending on the '-m32' option. As expected.

Next after that, was to check the multilib setup.
I doublechecked the guides and wikis, and everything is in order. I have [multilib] repository set in pacman.conf:

...
[multilib]
SigLevel = PackageRequired
Include = /etc/pacman.d/mirrorlist
...

I also tripple-checked the installation:

# pacman -S multilib-devel
:: There are 3 members in group multilib-devel:
:: Repository multilib
   1) binutils-multilib  2) gcc-multilib  3) libtool-multilib

Enter a selection (default=all): 

warning: binutils-multilib-2.23.1-1 is up to date -- reinstalling
warning: gcc-multilib-4.7.2-2 is up to date -- reinstalling
warning: libtool-multilib-2.4.2-7 is up to date -- reinstalling
resolving dependencies...
looking for inter-conflicts...

Targets (3): binutils-multilib-2.23.1-1  gcc-multilib-4.7.2-2  libtool-multilib-2.4.2-7

Total Installed Size:   99,48 MiB
Net Upgrade Size:       0,00 MiB

Proceed with installation? [Y/n] Y
(3/3) checking package integrity                                                                        [#############################################################] 100%
(3/3) loading package files                                                                             [#############################################################] 100%
(3/3) checking for file conflicts                                                                       [#############################################################] 100%
(3/3) checking available disk space                                                                     [#############################################################] 100%
(1/3) upgrading binutils-multilib                                                                       [#############################################################] 100%
(2/3) upgrading gcc-multilib                                                                            [#############################################################] 100%
(3/3) upgrading libtool-multilib                                                                        [#############################################################] 100%

...but yaourt (AUR) 32 bit source packages is still producing 64 bit binaries on packages that are supposed to be 32 bit.
What else can I do?

Last edited by SysGhost (2012-12-21 16:10:34)

Offline

#2 2012-12-21 03:15:52

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,355

Re: makepkg ignores CC and CXX variables. Cannot compile 32 bit binaries.

First things first, ALWAYS try using makepkg yourself....


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2012-12-21 13:39:35

SysGhost
Member
From: Stockholm
Registered: 2012-11-09
Posts: 62

Re: makepkg ignores CC and CXX variables. Cannot compile 32 bit binaries.

ngoonee wrote:

First things first, ALWAYS try using makepkg yourself....

Well... before that I need the compilation to produce the desired results. In my case a proper 32 bit binary.
I've tried to produce a 32 bit binary as one usually does, but with my Arch installation I'm missing something.

Example:

# git clone [url]https://github.com/LaurentGomila/SFML.git[/url]
*snip* git dowloads the source as intended. No errors.

# cd SFML
# mkdir build
# cd build
# export CC="gcc -m32"
# export CXX="g++ -m32"
# export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"
# cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DLIB_SUFFIX=32 -DLIB_INSTALL_DIR=/usr/lib32
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/libX11.so
-- Found OpenGL: /usr/lib/libGL.so  
-- Found Freetype: /usr/lib/libfreetype.so (found version "2.4.10") 
-- Found GLEW: /usr/lib/libGLEW.so  
-- Found JPEG: /usr/lib/libjpeg.so  
-- Found OpenAL: /usr/lib/libopenal.so  
-- Found SNDFILE: /usr/lib/libsndfile.so  
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    LIB_INSTALL_DIR


-- Build files have been written to: /home/sysghost/Sources/SFML/build

Here's the first problem: cmake uses /usr/lib/ instead of /usr/lib32/, despide the effort setting the variables. I'm not sure why it produces the LIB_INSTALL_DIR warning thou. It should work.

I can already here tell that it won't produce the desired 32 bit binaries, but let's try anyway:

# make
Scanning dependencies of target sfml-system
[  1%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.o
[  2%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Err.cpp.o
[  3%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Lock.cpp.o
[  5%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Mutex.cpp.o
[  6%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Sleep.cpp.o
[  7%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/String.cpp.o
[  9%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Thread.cpp.o
[ 10%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/ThreadLocal.cpp.o
[ 11%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Time.cpp.o
[ 12%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Unix/ClockImpl.cpp.o
[ 14%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Unix/MutexImpl.cpp.o
[ 15%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Unix/SleepImpl.cpp.o
[ 16%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Unix/ThreadImpl.cpp.o
[ 18%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Unix/ThreadLocalImpl.cpp.o
Linking CXX shared library ../../../lib/libsfml-system.so
[ 18%] Built target sfml-system
Scanning dependencies of target sfml-window
[ 19%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Context.cpp.o
[ 20%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/GlContext.cpp.o                                                                                       
[ 22%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/GlResource.cpp.o                                                                                      
[ 23%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Joystick.cpp.o                                                                                        
[ 24%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/JoystickManager.cpp.o                                                                                 
[ 25%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Keyboard.cpp.o                                                                                        
[ 27%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Mouse.cpp.o                                                                                           
[ 28%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/VideoMode.cpp.o                                                                                       
[ 29%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Window.cpp.o                                                                                          
[ 31%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/WindowImpl.cpp.o                                                                                      
[ 32%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Linux/Display.cpp.o                                                                                   
[ 33%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Linux/GlxContext.cpp.o                                                                                
[ 35%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Linux/InputImpl.cpp.o
[ 36%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Linux/JoystickImpl.cpp.o
[ 37%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Linux/VideoModeImpl.cpp.o
[ 38%] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Linux/WindowImplX11.cpp.o
Linking CXX shared library ../../../lib/libsfml-window.so
[ 38%] Built target sfml-window
Scanning dependencies of target sfml-network
[ 40%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/Ftp.cpp.o
[ 41%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/Http.cpp.o
[ 42%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/IpAddress.cpp.o
[ 44%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/Packet.cpp.o
[ 45%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/Socket.cpp.o
[ 46%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/SocketSelector.cpp.o
[ 48%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/TcpListener.cpp.o
[ 49%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/TcpSocket.cpp.o
[ 50%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/UdpSocket.cpp.o
[ 51%] Building CXX object src/SFML/Network/CMakeFiles/sfml-network.dir/Unix/SocketImpl.cpp.o
Linking CXX shared library ../../../lib/libsfml-network.so
[ 51%] Built target sfml-network
Scanning dependencies of target sfml-graphics
[ 53%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Color.cpp.o
[ 54%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Font.cpp.o
[ 55%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/GLCheck.cpp.o
[ 57%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Image.cpp.o
[ 58%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/ImageLoader.cpp.o
[ 59%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderStates.cpp.o
[ 61%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTexture.cpp.o
[ 62%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTextureImpl.cpp.o
[ 63%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTextureImplFBO.cpp.o
[ 64%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTextureImplDefault.cpp.o
[ 66%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTarget.cpp.o
[ 67%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderWindow.cpp.o
[ 68%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Shader.cpp.o
[ 70%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Shape.cpp.o
[ 71%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/CircleShape.cpp.o
[ 72%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RectangleShape.cpp.o
[ 74%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/ConvexShape.cpp.o
[ 75%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Sprite.cpp.o
[ 76%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Text.cpp.o
[ 77%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Texture.cpp.o
[ 79%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/TextureSaver.cpp.o
[ 80%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Transform.cpp.o
[ 81%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Transformable.cpp.o
[ 83%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/View.cpp.o
[ 84%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Vertex.cpp.o
[ 85%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/VertexArray.cpp.o
Linking CXX shared library ../../../lib/libsfml-graphics.so
[ 85%] Built target sfml-graphics
Scanning dependencies of target sfml-audio
[ 87%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/ALCheck.cpp.o
[ 88%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/AudioDevice.cpp.o
[ 89%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/Listener.cpp.o
[ 90%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/Music.cpp.o
[ 92%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/Sound.cpp.o
[ 93%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/SoundBuffer.cpp.o
[ 94%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/SoundBufferRecorder.cpp.o
[ 96%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/SoundFile.cpp.o
[ 97%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/SoundRecorder.cpp.o
[ 98%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/SoundSource.cpp.o
[100%] Building CXX object src/SFML/Audio/CMakeFiles/sfml-audio.dir/SoundStream.cpp.o
Linking CXX shared library ../../../lib/libsfml-audio.so
[100%] Built target sfml-audio

Compilation went off without a hinch. Let see what it produced:

# file libs/libsfml-system.so.2.0
lib/libsfml-system.so.2.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x7948c978199f5b329bd614c6f51ddcf7bbea8577, stripped

I guess I don't have to execute the make install, nor makepkg commands, as the result isn't what it supposed to be.

What else can I do?

(sfml-git is just an example, other packages I want to have a 32 bit version of gives the same result: Despite all my efforts to compile them in 32 bit, it still produces 64 bit binaries.)



EDIT:
After much trial and error, I found out I've been messing up env. variables badly. After a reboot, i Was able to produce the desired 32 bit binaries manually. But I still have trouble with the PKGBUILD.

The problem now is:
If I run these commands manually, it wors as intended:

# git clone [url]https://github.com/LaurentGomila/SFML.git[/url]
*snip* git dowloads the source as intended. No errors.

# cd SFML
# mkdir build
# cd build
# export CC="gcc -m32"
# export CXX="g++ -m32"
# export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"
# cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DLIB_SUFFIX=32 -DLIB_INSTALL_DIR=/usr/lib32
*snip* Normal output from cmake.

# make

It ends up with the desired result:
lib/libsfml-system.so.2.0: ELF 32-bit LSB shared object, Intel 80386, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=0xba9a764d794e7b3df254ed18286a6cef32b19b44, not stripped

but if I put these very exact  commands in a PKGBUILDs build() function, it doesn't work as intended anymore.
I suspect that the export of the C and CXX variables are skipped when used with makepkg.



The PKGBUILD that mysteriosly ignores the export commands:

_pkgbasename=sfml
pkgname=lib32-${_pkgbasename}-git
pkgver=20121221
pkgrel=1
pkgdesc='A simple, fast, cross-platform, and object-oriented multimedia API (32-bit))'
arch=('x86_64')
url='http://www.sfml-dev.org/'
license=('zlib')
depends=("$_pkgbasename" 'lib32-libsndfile' 'lib32-libxrandr' 'lib32-libjpeg' 'lib32-openal' 'lib32-glew' 'lib32-freetype2')
makedepends=('gcc-multilib' 'git' 'lib32-mesa' 'cmake')
options=('!libtool')

_gitroot='https://github.com/LaurentGomila/SFML.git'
_gitname='SFML'


build() {
  cd "$srcdir"
  git clone $_gitroot

  rm -rf "$srcdir/$_gitname-build"
  cp -r "$srcdir/$_gitname" "$srcdir/$_gitname-build"
  cd "$srcdir/$_gitname-build"

  mkdir build
  cd build

  export CC="gcc -m32"
  export CXX="g++ -m32"
  export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"

  cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DLIB_SUFFIX=32 -DLIB_INSTALL_DIR=/usr/lib32
  make
}

package() {
  cd "$srcdir/$_gitname-build/build"
  make DESTDIR="$pkgdir/" install

  # those are already included in the sfml package
  rm -rf "$pkgdir/usr/share" "$pkgdir/usr/include"

  make clean
}

Last edited by SysGhost (2012-12-21 15:51:31)

Offline

Board footer

Powered by FluxBB