Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#10237 closed bug (fixed)

hsc2hs : compiler/ghci/LibFFI.hsc:42 sizeof(ffi_cif) is not an integer

Reported by: erikd Owned by:
Priority: normal Milestone: 8.0.1
Component: Compiler Version: 7.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by erikd)

Cross-compiling git HEAD from linux-amd64 to linux-aarch64 and I get the above error message. The command (after removing a bunhc of irrelevant command line flags) is:

inplace/bin/hsc2hs --cc=/usr/bin/aarch64-linux-gnu-gcc \
  --ld=/usr/bin/aarch64-linux-gnu-gcc \
  --cross-safe --cflag=-fno-stack-protector --cross-compile \
  --cflag=-Daarch64_HOST_ARCH=1 \
  --cflag=-Dlinux_HOST_OS=1 --cflag=-D__GLASGOW_HASKELL__=711 \
  --cflag=-Icompiler/../rts/dist/build \
  --cflag=-Werror=unused-but-set-variable \
  --cflag=-include \
  --cflag=compiler/stage2/build/autogen/cabal_macros.h \
  compiler/ghci/LibFFI.hsc -o compiler/stage2/build/LibFFI.hs

The command grep 'sizeof(ffi_cif)' compiler/ghci/LibFFI.hsc finds:

    cif <- mallocBytes (#const sizeof(ffi_cif))

Native compile on this system works fine.

Checking out an older revision that was know to compile correctly also fails. That suggests that something in the tool chain has changed. My GHC is still 7.8.3, but aarch64-linux-gnu-gcc was recently updated.

Attachments (1)

0001-Fix-error-when-cross-compiling-during-GHC-build.patch (2.6 KB) - added by erikd 3 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 3 years ago by erikd

Description: modified (diff)

comment:2 Changed 3 years ago by erikd

Nope, aarch64-linux-gnu-gcc was changed over a month ago and this was working much more recently than that.

comment:3 Changed 3 years ago by erikd

Ok, here's the problem:

LibFFI.hsc: In function ‘_hsc2hs_test’:
LibFFI.hsc:11:14: error: variable ‘test_array’ set but not used [-Werror=unused-but-set-variable]
cc1: some warnings being treated as errors

It seems hsc2hs generates some test files to measure the size of values that looks like this:

void _hsc2hs_test() {
  static int test_array[1 - 2 * !((long long)(sizeof(ffi_cif)) == (sizeof(ffi_cif)))];
  test_array[0] = 0;
}

The value of test_array[0] is set but not used.

I wonder why this is happening during cross-compiling but not during native compiles.

Last edited 3 years ago by erikd (previous) (diff)

comment:4 Changed 3 years ago by erikd

Ah, the code path is different for the native compiler case.

comment:5 Changed 3 years ago by erikd

Status: newpatch

Patch attached.

comment:6 Changed 3 years ago by erikd

Summary: compiler/ghci/LibFFI.hsc:42 sizeof(ffi_cif) is not an integerhsc2hs : compiler/ghci/LibFFI.hsc:42 sizeof(ffi_cif) is not an integer

comment:7 Changed 3 years ago by rwbarton

Resolution: fixed
Status: patchclosed

I pushed this for now but it would be good to have something that is more robust to changes in warnings. See #9457.

comment:8 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

Note: See TracTickets for help on using tickets.