Bug 104819 - [libdrm build failure on 32 bit Ubuntu 16.04] libdrm_macros.h:79:4: error: size of unnamed array is negative
Summary: [libdrm build failure on 32 bit Ubuntu 16.04] libdrm_macros.h:79:4: error: si...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: git
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-28 17:03 UTC by Fabio Pedretti
Modified: 2018-01-31 16:04 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Fabio Pedretti 2018-01-28 17:03:14 UTC
One of latest libdrm commits make libdrm fails to build on 32 bit Ubuntu 16.06. Builds fine on 64 bit and newer Ubuntus. Error:

make[4]: Entering directory '/<<BUILDDIR>>/libdrm-2.4.89+git1801270630.6f0f6c~oibaf~x/build/tests/amdgpu'
../../../tests/amdgpu/basic_tests.c: In function ‘amdgpu_userptr_test’:
../../../tests/amdgpu/basic_tests.c:1397:2: warning: ignoring return value of ‘posix_memalign’, declared with attribute warn_unused_result [-Wunused-result]
  posix_memalign(&ptr, sysconf(_SC_PAGE_SIZE), BUFFER_SIZE);
  ^
In file included from ../../../amdgpu/amdgpu_internal.h:35:0,
                 from ../../../tests/amdgpu/vm_tests.c:28:
../../../libdrm_macros.h: In function ‘drm_munmap’:
../../../libdrm_macros.h:79:4: error: size of unnamed array is negative
    STATIC_ASSERT(LARGE_OFF_T % 2147483629 == 721 &&
    ^
Makefile:616: recipe for target 'amdgpu_test-vm_tests.o' failed
make[4]: *** [amdgpu_test-vm_tests.o] Error 1
make[4]: Leaving directory '/<<BUILDDIR>>/libdrm-2.4.89+git1801270630.6f0f6c~oibaf~x/build/tests/amdgpu'

Full build log including configure flags:
https://launchpadlibrarian.net/354844704/buildlog_ubuntu-xenial-i386.libdrm_2.4.89+git1801270630.6f0f6c~oibaf~x_BUILDING.txt.gz
Comment 1 Robert Wahlstedt 2018-01-29 01:32:55 UTC
Hi, There are two different drivers, a 64 bit driver and a 32 bit driver. Please make sure you have the 32 bit one. This sounds like the 64 bit driver has been downloaded. There are different bis consumed by a 32 bit int and a 64 int and this messes with thread safety which in turn messages with signals given by the operating system.
Comment 2 Fabio Pedretti 2018-01-29 14:30:34 UTC
Note I am compiling the drm source from git. The same source builds fine on newer Ubuntu. Maybe it's something broken/old in the ubuntu 16.04 toolchain?
Comment 3 Eric Engestrom 2018-01-29 14:45:12 UTC
I think you might be hitting a bug combining C++ compilers trying to compile C and autotools not being smart enough.
What happens if you try to build using Meson?

(If you've never used Meson before, Mesa has a good page describing how to use it: https://mesa3d.org/meson.html)
Comment 4 Emil Velikov 2018-01-29 14:52:22 UTC
(In reply to Eric Engestrom from comment #3)
> I think you might be hitting a bug combining C++ compilers trying to compile
> C and autotools not being smart enough.
> What happens if you try to build using Meson?
> 
> (If you've never used Meson before, Mesa has a good page describing how to
> use it: https://mesa3d.org/meson.html)

That's a lot of bull**** and you know it ;-) This is pre-processor stuff, where autotools or any build system doesn't care.

Issue is a missing config.h include in the C file. I'll send a patch in a moment.
Comment 5 Emil Velikov 2018-01-31 16:04:32 UTC
The following commit should resolve it. Although we might want to consider using gcc/clang -include config.h and drop the explicit includes from the code.

commit 10e85a8b7f28e80f5184919b2448ade18c19ca21
Author: Emil Velikov <emil.velikov@collabora.com>
Date:   Mon Jan 29 14:51:31 2018 +0000

    tests/amdgpu: add missing config.h include


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.