vmchale / libarchive

Haskell bindings to libarchive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to build on 32bit?

hasufell opened this issue · comments

https://gitlab.haskell.org/haskell/ghcup-hs/-/jobs/389171#L1140

Failed to build libarchive-2.2.5.1.
Build log (
/root/.cabal/logs/ghc-8.8.3/libarchive-2.2.5.1-d103ccbffd32283b7736e9e12d79adde3db950140e658aaa091dad14c3c8345a.log
):
[1 of 1] Compiling Main             ( /builds/haskell/ghcup-hs/dist-newstyle/tmp/src-2035/libarchive-2.2.5.1/dist/setup/setup.hs, /builds/haskell/ghcup-hs/dist-newstyle/tmp/src-2035/libarchive-2.2.5.1/dist/setup/Main.o )
Linking /builds/haskell/ghcup-hs/dist-newstyle/tmp/src-2035/libarchive-2.2.5.1/dist/setup/setup ...
Configuring libarchive-2.2.5.1...
Preprocessing library for libarchive-2.2.5.1..
c2hs: C header contains errors:
/usr/include/bits/alltypes.h:71: (column 18) [ERROR]  >>> Syntax error !
  The symbol `_Alignas' does not fit here.
cabal: Failed to build libarchive-2.2.5.1 (which is required by exe:ghcup from
ghcup-0.1.5 and exe:ghcup-gen from ghcup-0.1.5). See the build log above for
details.

haskell/c2hs#255

Do you happen to have /usr/include/bits/alltypes.h on line 71? I wonder if it can be worked around by #includeing something?

Any ideas? This is blocking next ghcup release :/

Unfortunately, no; I'm far from a C expert 😬

Is it possible to not use c2hs? What are the other options?

Maybe? hsc2hs is another option; c2hs is pretty deep in libarchive, it could be taken out in theory but it's difficult to get things to work cross-platform (e.g. on arm 32-bit).

Ideally we would fix c2hs or language-c... perhaps time for a mailing list post :p

Does #define _Alignas(t) __attribute__((__aligned__(t))) work? Or maybe #include <stdalign.h> 😬

Does getting rid of cc-options: -std=gnu99 help?

This is in musl stdalign.h

#ifndef _STDALIGN_H
#define _STDALIGN_H

#ifndef __cplusplus

/* this whole header only works in C11 or with compiler extensions */
#if __STDC_VERSION__ < 201112L && defined( __GNUC__)
#define _Alignas(t) __attribute__((__aligned__(t)))
#define _Alignof(t) __alignof__(t)
#endif

#define alignas _Alignas
#define alignof _Alignof

#endif

#define __alignas_is_defined 1
#define __alignof_is_defined 1

#endif

Have a look at 96ad5c6, it switches from gnu99 to c11.

haskell/c2hs#268 more errors I experience on fedora now, so I can't build libarchive on my main box

Wow, that's no good. Is that avoidable with hsc2hs or something like it?

Does something like

allow-newer:
  c2hs:language-c

work?

$ cabal build --allow-newer=c2hs --allow-newer=language-c                                                                            2m  Tue 17:56
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
 - libarchive-3.0.2.0 (lib:libarchive) (first run)
Preprocessing library for libarchive-3.0.2.0..
c2hs: Codec/Archive/Types/Foreign.chi not found in:
/home/hasufell/git/libarchive/dist-newstyle/build/x86_64-linux/ghc-8.10.4/libarchive-3.0.2.0/build
.

I think that's a cabal/cabal-install bug? You could try cabal clean && cabal build --allow-newer=language-c

I think that's a cabal/cabal-install bug? You could try cabal clean && cabal build --allow-newer=language-c

That seems to have worked