Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 625844 - media-libs/vulkan-loader-1.0.54.0: fails to build for abi_x86_32 (missing ASFLAGS=--32)
Summary: media-libs/vulkan-loader-1.0.54.0: fails to build for abi_x86_32 (missing ASF...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo X packagers
URL: https://github.com/KhronosGroup/Vulka...
Whiteboard:
Keywords: TESTFAILURE
: 632263 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-07-21 10:51 UTC by Alexander Tsoy
Modified: 2018-03-24 00:10 UTC (History)
19 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
vulkan-loader-1.0.54.0:20170721-104649.log (vulkan-loader-1.0.54.0:20170721-104649.log,140.43 KB, text/plain)
2017-07-21 10:51 UTC, Alexander Tsoy
Details
emerge info (emerge_info,5.76 KB, text/plain)
2017-07-22 13:13 UTC, mercuriete
Details
vulkan build log (build_vulkan.log,140.18 KB, text/x-log)
2017-07-22 13:13 UTC, mercuriete
Details
build.log (build.log,141.22 KB, text/x-log)
2017-09-30 17:13 UTC, mercuriete
Details
disables the 32bit assembler test (disable-asm-test-32.patch,674 bytes, patch)
2017-10-22 13:03 UTC, Machredsch
Details | Diff
New ebuild that sets ASFLAGS appropriately (vulkan-loader-1.0.65.2.ebuild,1.51 KB, text/plain)
2018-01-31 23:55 UTC, James Le Cuirot
Details
New ebuild that sets ASFLAGS appropriately (vulkan-loader-1.0.65.2.ebuild,1.54 KB, text/plain)
2018-02-01 22:39 UTC, James Le Cuirot
Details
New ebuild that uses tc-getCC (vulkan-loader-1.0.65.2.ebuild,1.60 KB, text/plain)
2018-02-03 20:39 UTC, James Le Cuirot
Details
eclass patch to add CMAKE_ASM-ATT_LINK_FLAGS (asm-att.patch,1.34 KB, patch)
2018-03-12 23:46 UTC, James Le Cuirot
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Tsoy 2017-07-21 10:51:31 UTC
Created attachment 486264 [details]
vulkan-loader-1.0.54.0:20170721-104649.log

vulkan-loader-1.0.54.0 fails to build for 32 bit abi:

/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm: Assembler messages:                       
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:373: Error: operand type mismatch for `push'           
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:373: Error: operand type mismatch for `jmp'                                     
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:374: Error: operand type mismatch for `push'
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:374: Error: operand type mismatch for `jmp'
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:375: Error: operand type mismatch for `push'                                    
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:375: Error: operand type mismatch for `jmp'
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:376: Error: operand type mismatch for `push'
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:376: Error: operand type mismatch for `jmp'                                     
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:377: Error: operand type mismatch for `push'
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0/loader/unknown_ext_chain_gas.asm:377: 
...
...

$ emerge --info vulkan-loader
Portage 2.3.6 (python 3.4.5-final-0, hardened/linux/amd64, gcc-6.3.0, glibc-2.23-r4, 4.12.2-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.12.2-gentoo-x86_64-AMD_Opteron-tm-_Processor_4332_HE-with-gentoo-2.3
KiB Mem:    32993284 total,  22568880 free
KiB Swap:   16777212 total,  16777212 free
Timestamp of repository gentoo: Fri, 21 Jul 2017 00:45:01 +0000
sh dash 0.5.8.2
ld GNU ld (Gentoo 2.28 p1.2) 2.28
distcc 3.2rc1 x86_64-pc-linux-gnu [disabled]
app-shells/bash:          4.3_p48-r1::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.1-r2::gentoo
dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo
dev-util/cmake:           3.7.2::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.26.3::gentoo
sys-apps/sandbox:         2.10-r3::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.28-r2::gentoo
sys-devel/gcc:            6.3.0::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r4::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: webrsync
    sync-uri: http://mirror.yandex.ru/gentoo-distfiles/
    priority: -1000

crossdev
    location: /var/db/repos/crossdev
    masters: gentoo
    priority: 100

puleglot
    location: /var/db/repos/puleglot
    sync-type: git
    sync-uri: git://puleglot.ru/gentoo/puleglot-overlay.git
    masters: gentoo
    priority: 900

local
    location: /usr/local/portage
    masters: gentoo
    priority: 1000

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=bdver2 -mtune=bdver2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/easy-rsa /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/chromium/policies/managed/chrome-gnome-shell.json /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/opt/chrome/policies/managed/chrome-gnome-shell.json /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=bdver2 -mtune=bdver2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --binpkg-respect-use=y --ask-enter-invalid"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildsyspkg compress-build-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms split-log strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles/"
LANG="ru_RU.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j6"
PKGDIR="/var/cache/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X aac acl acpi aio alsa amd64 amr ape asyncns avahi bash-completion berkdb bluetooth bluray branding bzip2 cairo caps cdda cddb cdparanoia cdr cli colord cracklib crypt cryptsetup cups cxx dbus dconf device-mapper djvu dri dts dvd dvdr eds egl evo examples exif faac faad ffmpeg flac fontconfig fuse gdbm gif gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk gtk3 hardened iconv icu idn ieee1394 introspection ipv6 jpeg jpeg2k justify lcms libass libnotify libsecret lz4 lzma mac maildir mms modules mp3 mp4 multilib musepack musicbrainz nautilus ncurses networkmanager nls nptl ogg opengl openmp opus pam pax_kernel pcre perl pie png policykit postscript pulseaudio python raw readline samba sasl seccomp session speex spell ssl ssp startup-notification svg systemd tcpd theora tiff tls truetype udev unicode upnp-av urandom usb vaapi vdpau vim-syntax vorbis vpx wavpack webp x264 xattr xfs xtpax xv xvid xz zeroconf zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" APACHE2_MPMS="prefork" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="*" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3 sse4_1 sse4_2 avx fma3 xop aes f16c" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="evdev libinput" KERNEL="linux" L10N="en ru" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US ru ru_RU" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" QEMU_SOFTMMU_TARGETS="aarch64 arm i386 mips mips64 mips64el mipsel x86_64" QEMU_USER_TARGETS="arm" RUBY_TARGETS="ruby21 ruby22" USERLAND="GNU" VIDEO_CARDS="amdgpu radeon radeonsi vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

media-libs/vulkan-loader-1.0.54.0::gentoo was built with the following:
USE="X -wayland" ABI_X86="(64) -32 (-x32)"
Comment 1 Alexander Tsoy 2017-07-21 11:21:52 UTC
It needs environment variable ASFLAGS=--32
https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/commit/58165eb7108df7af118b9605658cb9fc86bb2512
Comment 2 Alexander Tsoy 2017-07-21 12:34:30 UTC
I've tried the following patch:

@@ -33,6 +33,9 @@
 }

 multilib_src_configure() {
+       if [[ ${ABI} == x86 ]]; then
+               export ASFLAGS=--32
+       fi
        local mycmakeargs=(
                -DCMAKE_SKIP_RPATH=True
                -DBUILD_TESTS=False
@@ -46,6 +49,7 @@
                -DBUILD_WSI_XLIB_SUPPORT=$(usex X)
        )
        cmake-utils_src_configure
+       unset ASFLAGS
 }

 multilib_src_install() {


With that patch assembler test fails, however packages builds fine.

-- Found assembler: /usr/bin/as
CMake Warning at loader/CMakeLists.txt:122 (message):
  Could not find working x86 GAS assembler

  The build will fall back on building with C code

  Note that this may be unsafe, as the C code requires tail-call
  optimizations to remove the stack frame for certain calls.  If the compiler
  does not do this, then unknown device extensions will suffer from a
  corrupted stack.
Comment 3 Mike Lothian 2017-07-21 21:45:24 UTC
I think there's something wrong with that test
Comment 4 Mike Lothian 2017-07-21 21:46:44 UTC
To clarify, I've been trying to add ASFLAGS support to multilib, all avenues lead back to "Could not find working x86 GAS assembler"
Comment 5 mercuriete 2017-07-22 13:12:34 UTC
Same problem.

dont know why but when compiling with:

~ $ equery uses vulkan-loader 
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for media-libs/vulkan-loader-1.0.54.0:
 U I
 + + X          : Add support for X11
 + - abi_x86_32 : 32-bit (x86) libraries
 - - wayland    : Enable dev-libs/wayland backend

It fails.

see next attachements of my emerge --info and build.log
Comment 6 mercuriete 2017-07-22 13:13:23 UTC
Created attachment 486458 [details]
emerge info
Comment 7 mercuriete 2017-07-22 13:13:58 UTC
Created attachment 486460 [details]
vulkan build log
Comment 8 Alexander Tsoy 2017-07-23 00:56:50 UTC
After adding --debug-trycompile to $mycmakeargs I get this:

# pwd
/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0-r1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0-abi_x86_32.x86/loader/CMakeFiles/CMakeTmp
# cat CMakeFiles/cmTC_12db8.dir/link.txt
/usr/bin/ld  --32 -I"/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0-r1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0-abi_x86_32.x86/loader"     CMakeFiles/cmTC_12db8.dir/asm_test.asm.o  -o cmTC_12db8
# /usr/bin/ld  --32 -I"/var/tmp/portage/media-libs/vulkan-loader-1.0.54.0-r1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.54.0-abi_x86_32.x86/loader"     CMakeFiles/cmTC_12db8.dir/asm_test.asm.o  -o cmTC_12db8
/usr/bin/ld: unrecognized option '--32'
/usr/bin/ld: use the --help option for usage information
#

So "--32" is being added the linker flags which is wrong.
Comment 9 Ooblick 2017-09-29 14:26:04 UTC
I see 1.0.61.1 is now released https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/releases/tag/sdk-1.0.61.1 Wonder if this is still an issue.
Comment 10 mercuriete 2017-09-30 17:13:45 UTC
Created attachment 497250 [details]
build.log

same bug in 1.0.61.1
Comment 11 Michal Jakubowski 2017-10-02 21:23:43 UTC
(In reply to mercuriete from comment #10)
> Created attachment 497250 [details]
> build.log
> 
> same bug in 1.0.61.1

Confirm.
Comment 12 Mike Auty (RETIRED) gentoo-dev 2017-10-04 16:49:15 UTC
*** Bug 632263 has been marked as a duplicate of this bug. ***
Comment 13 Mike Auty (RETIRED) gentoo-dev 2017-10-04 16:56:12 UTC
This doesn't yet appear
Comment 14 Mike Auty (RETIRED) gentoo-dev 2017-10-04 16:56:55 UTC
Sorry, the comment was in error, I only meant to set the keyword.
Comment 15 Alexander Tsoy 2017-10-04 18:18:57 UTC
Well, build failure and assembler test failure are actually different bugs. The former can be easily fixed, see comment 2.
Comment 16 Matt Turner gentoo-dev 2017-10-21 02:13:13 UTC
(In reply to Alexander Tsoy from comment #15)
> Well, build failure and assembler test failure are actually different bugs.
> The former can be easily fixed, see comment 2.

Your fix for the build failure just (inadvertently?) disables the assembly.
Comment 17 Machredsch 2017-10-22 13:03:20 UTC
Created attachment 499654 [details, diff]
disables the 32bit assembler test

(In reply to Matt Turner from comment #16)
> (In reply to Alexander Tsoy from comment #15)
> > Well, build failure and assembler test failure are actually different bugs.
> > The former can be easily fixed, see comment 2.
> 
> Your fix for the build failure just (inadvertently?) disables the assembly.

Yes, the ebuild exports the correct flag as described, but because of the failed assembler test, assembling is disabled.
So for a temporary (and ugly) solution, just to get the emerge with assembler done, I disabled the 32bit assembler test in "loader/CMakeLists.txt".
I used the updated ebuild, see comment 2 and it worked for me.

I only have some rudimental coding knowledge, but it seems to me, the test uses the 64bit "/usr/bin/as" without the correct option passed, whereas the compiling is working correctly, if "--32" is exported before and the test was succesful.
Please correct this, if I am wrong.
Comment 18 Alexander Tsoy 2017-12-14 19:30:14 UTC
(In reply to Matt Turner from comment #16)

> Your fix for the build failure just (inadvertently?) disables the assembly.

Yes, I know. That was the plan: fix build failure first and then wait for assembler detection fix from upstream. %)
Comment 20 Mads 2018-01-18 00:23:46 UTC
Tried compiling 1.0.61.1 with this patch enabled, but I can't get it to work. With ASFLAGS="--32", 32 bit compiles, with no ASFLAGS, 64 bit compiles. Don't know what I have to do to get both to compile.
Comment 21 James Le Cuirot gentoo-dev 2018-01-31 23:55:24 UTC
Created attachment 517326 [details]
New ebuild that sets ASFLAGS appropriately

Try this on for size. It's a bump to the latest version, which unfortunately doesn't include the patch above so you'll need to grab that too, and it also sets ASFLAGS appropriately.

Annoyingly the flags haven't been set up in the multilib profiles. Perhaps they should be? Evidently it's not needed much. Maybe the CMAKE_ASM-ATT_COMPILER definition could also go into the toolchain file written by cmake-utils.eclass.

I was surprised that tc-getAS returns x86_64-pc-linux-gnu-as for native and just "as" for the x86 ABI. I don't know why that is as I cannot find definitions for gcc or g++ anywhere either. I suspect this won't work when cross-compiling, not that anyone would.

Fellow devs, what do you think?
Comment 22 Alexander Tsoy 2018-02-01 00:56:06 UTC
(In reply to James Le Cuirot from comment #21)
> I was surprised that tc-getAS returns x86_64-pc-linux-gnu-as for native and
> just "as" for the x86 ABI. I don't know why that is as I cannot find
> definitions for gcc or g++ anywhere either. I suspect this won't work when
> cross-compiling, not that anyone would.
I think this is due to:
1. multilib.eclass sets CHOST_x86=${CTARGET/x86_64/i686}
2. _tc-getPROG() from toolchain-funcs.eclass prints just "as", "gcc", etc because there is no such executable named ${!tuple}-${prog[0]} for x86 ABI.

$ type -p x86_64-pc-linux-gnu-as 
/usr/bin/x86_64-pc-linux-gnu-as
$ type -p i686-pc-linux-gnu-as 
$ 

I don't understand why multilib.eclass is touching CHOST. Changing CTARGET should be enough.
Comment 23 James Le Cuirot gentoo-dev 2018-02-01 22:39:14 UTC
Created attachment 517508 [details]
New ebuild that sets ASFLAGS appropriately

Here's a new version of that ebuild that includes --64 as the x32 profile can actually build for all 3 ABIs.

(In reply to Alexander Tsoy from comment #22)
> (In reply to James Le Cuirot from comment #21)
> > I was surprised that tc-getAS returns x86_64-pc-linux-gnu-as for native and
> > just "as" for the x86 ABI. I don't know why that is as I cannot find
> > definitions for gcc or g++ anywhere either. I suspect this won't work when
> > cross-compiling, not that anyone would.
> I think this is due to:
> 1. multilib.eclass sets CHOST_x86=${CTARGET/x86_64/i686}
> 2. _tc-getPROG() from toolchain-funcs.eclass prints just "as", "gcc", etc
> because there is no such executable named ${!tuple}-${prog[0]} for x86 ABI.
That's an interesting find but the multilib_env function in multilib.eclass is only used by the glibc ebuild. It's not referenced by any eclass. Furthermore, when building for the x86 ABI, it still calls gcc as x86_64-pc-linux-gnu-gcc but with the -m32 argument added.
Comment 24 Alexander Tsoy 2018-02-01 22:52:22 UTC
(In reply to James Le Cuirot from comment #23)
Ah.. yes, indeed.
Comment 25 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-03 14:39:53 UTC
Long story short, our multilib logic doesn't account for 'as' executable at all. Probably because no package so far has been using it directly.

As for an easy solution, please try if you can compile those assembly files with $(CC). If it works, then there's no need to do anything further because GCC will take care of calling 'as' correctly.

If that is not possible, then multilib.eclass + profiles should be enhanced to specify ASFLAGS for various ABIs, and then the former to override AS. Note: unclear if this won't break existing packages.
Comment 26 James Le Cuirot gentoo-dev 2018-02-03 20:39:16 UTC
Created attachment 517686 [details]
New ebuild that uses tc-getCC

(In reply to Michał Górny from comment #25)
> As for an easy solution, please try if you can compile those assembly files
> with $(CC). If it works, then there's no need to do anything further because
> GCC will take care of calling 'as' correctly.
> 
> If that is not possible, then multilib.eclass + profiles should be enhanced
> to specify ASFLAGS for various ABIs, and then the former to override AS.
> Note: unclear if this won't break existing packages.
It took some figuring out but I managed to convince it to accept ${CC} instead. The key difference is that ${CC} normally links as well so you have to add the -c argument.

The sucky part is that gcc doesn't know what to do with .asm files. The good news is that CMake also knows about .s so you can just rename and sed and it all just works.

We could ask upstream to rename but then they'd ask why so we could try to convince them to use ${CC} instead. On the other hand, they are leveraging standard CMake functionality that's really geared towards "as" and it's probably best if they don't deviate from that. It's CMake that sucks here, not upstream. 

So maybe just renaming without changing anything else would be a good compromise. It would then be short and simple enough to just deal with in this package, negating the risk of breaking anything by touching the eclass.
Comment 27 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-03 20:49:26 UTC
You can try to look for other projects using CMake. I'm pretty sure it's uncommon to actually call 'as' directly.
Comment 28 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-03 20:59:02 UTC
Actually, we are enforcing using CC for assembly in cmake-utils.eclass:

  SET (CMAKE_ASM_COMPILER "${myCC/ /;}")

However, FWICS upstream uses 'ASM-ATT' instead of 'ASM', so our rule doesn't catch. If gcc supports compiling AT&T syntax as well, we should probably extend cmake-utils.eclass to override that one as well, e.g.:

  SET (CMAKE_ASM-ATT_COMPILER "${myCC/ /;}")

If you could test that, I'd appreciate. In that case, it's just a matter of convincing upstream that .s/.S is the standard suffix for assembly files and it's more portable than .asm, with the latter breaking our configuration.
Comment 29 Maxime Lombard 2018-02-25 00:08:30 UTC
(In reply to Michał Górny from comment #28)
> Actually, we are enforcing using CC for assembly in cmake-utils.eclass:
> 
>   SET (CMAKE_ASM_COMPILER "${myCC/ /;}")
> 
> However, FWICS upstream uses 'ASM-ATT' instead of 'ASM', so our rule doesn't
> catch. If gcc supports compiling AT&T syntax as well, we should probably
> extend cmake-utils.eclass to override that one as well, e.g.:
> 
>   SET (CMAKE_ASM-ATT_COMPILER "${myCC/ /;}")
> 
> If you could test that, I'd appreciate. In that case, it's just a matter of
> convincing upstream that .s/.S is the standard suffix for assembly files and
> it's more portable than .asm, with the latter breaking our configuration.

Hi Michał,

I can confirm that your modification works for me. After to modify "SET (CMAKE_ASM_COMPILER "${myCC/ /;}")" to "SET (CMAKE_ASM-ATT_COMPILER "${myCC/ /;}")" and re-launch the emerge of vulkan-loader, the compilation/installation work.

I use gcc 7.3.0.

Cheers,
Maxime
Comment 30 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-26 17:10:36 UTC
Maxime, does that mean that the rename is no longer necessary?
Comment 31 James Le Cuirot gentoo-dev 2018-03-02 21:24:53 UTC
(In reply to Michał Górny from comment #30)
> Maxime, does that mean that the rename is no longer necessary?

I tried the eclass patch and the rename is not necessary. Weird. But good. :)
Comment 32 Maxime Lombard 2018-03-03 15:26:52 UTC
(In reply to Michał Górny from comment #30)
> Maxime, does that mean that the rename is no longer necessary?

Yes, apply the modification in "cmake-utils.eclass" was enough for me.
Comment 33 Larry the Git Cow gentoo-dev 2018-03-10 11:35:18 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a247887d826ce2786dcfd2a380a227b188d4964b

commit a247887d826ce2786dcfd2a380a227b188d4964b
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2018-02-25 09:06:06 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2018-03-10 11:35:13 +0000

    cmake-utils.eclass: Extend ASM rules to ASM-ATT
    
    Some CMake projects use ASM-ATT rather than ASM, so extend our rule
    overrides to that.
    
    Closes: https://bugs.gentoo.org/625844

 eclass/cmake-utils.eclass | 3 +++
 1 file changed, 3 insertions(+)
Comment 34 Alexander Tsoy 2018-03-11 12:10:56 UTC
And now assembler config check fails for both x86_64 and x86_32. I'll try to provide more info later.
Comment 35 James Le Cuirot gentoo-dev 2018-03-11 13:33:13 UTC
(In reply to Alexander Tsoy from comment #34)
> And now assembler config check fails for both x86_64 and x86_32. I'll try to
> provide more info later.

Damn, I must have missed that. I see it now. I'll dig in.
Comment 36 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-03-11 13:36:04 UTC
(In reply to Alexander Tsoy from comment #34)
> And now assembler config check fails for both x86_64 and x86_32. I'll try to
> provide more info later.

It worked for me.
Comment 37 Alexander Tsoy 2018-03-11 16:10:21 UTC
Looks like .s/.S suffix is needed:

# pwd
/var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader/CMakeFiles/CMakeTmp
# x86_64-pc-linux-gnu-gcc -m32 -DNDEBUG -I"/var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader"    -o CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o -c /var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader/asm_test.asm
x86_64-pc-linux-gnu-gcc: warning: /var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader/asm_test.asm: linker input file unused because linking not done
# ls -l CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o
ls: cannot access 'CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o': No such file or directory
# mv /var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader/asm_test.{asm,S}
# x86_64-pc-linux-gnu-gcc -m32 -DNDEBUG -I"/var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader"    -o CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o -c /var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader/asm_test.S  
# ls -l CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o
-rw-r--r-- 1 root root 468 Mar 11 19:06 CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o
Comment 38 Alexander Tsoy 2018-03-11 16:14:29 UTC
"-x assembler" also works:

# rm -fv CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o
removed 'CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o'
# x86_64-pc-linux-gnu-gcc -m32 -x assembler -DNDEBUG -I"/var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader"    -o CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o -c /var/tmp/portage/media-libs/vulkan-loader-1.0.61.1/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.61.1-abi_x86_32.x86/loader/asm_test.asm
# ls -l CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o-rw-r--r-- 1 root root 468 Mar 11 19:13 CMakeFiles/cmTC_b78d2.dir/asm_test.asm.o
Comment 39 James Le Cuirot gentoo-dev 2018-03-12 23:46:18 UTC
Created attachment 523674 [details, diff]
eclass patch to add CMAKE_ASM-ATT_LINK_FLAGS

This helps a little in that the ASM stuff actually builds now but the 32-bit version ends up with TEXTRELs. I don't know whether this is normal because I now realise that none of my earlier patches actually worked.
Comment 40 James Le Cuirot gentoo-dev 2018-03-13 00:01:15 UTC
Aha, the TEXTREL is fixed by this.

https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/commit/560f9cdf78d3d03dbf97be638becd1a7df5fa154

I did try a newer version but there's stupid crap going on with a dependency on an external gslang repository. We should get the eclass patch merged and I'll try to figure out the rest.
Comment 41 Matt Turner gentoo-dev 2018-03-13 00:16:16 UTC
glslang is now in tree. sarnex is working on FEATURES=test support for vulkan-loader now, which likely requires packaging spirv-tools/headers too.

Happy to see people working on this assembly issue.
Comment 42 James Le Cuirot gentoo-dev 2018-03-15 22:51:57 UTC
(In reply to Matt Turner from comment #41)
> glslang is now in tree. sarnex is working on FEATURES=test support for
> vulkan-loader now, which likely requires packaging spirv-tools/headers too.

Turns out the glslang dependency was bogus as it shouldn't be required if you're not building the validation layers, which we're not. I've submitted a patch.

https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/pull/2488

With this, 1.1.70.0 builds and works. I think this is for the move to Vulkan 1.1 but there's no soname change.
Comment 43 James Le Cuirot gentoo-dev 2018-03-16 23:05:23 UTC
Could someone please confirm that my eclass patch from comment #39 works for them before I submit it to the mailing list? Pay close attention to the configure output. If you see this then it didn't work:

> Could not find working x86 GAS assembler
>
> The build will fall back on building with C code
>
> Note that this may be unsafe, as the C code requires tail-call
> optimizations to remove the stack frame for certain calls.  If the compiler
> does not do this, then unknown device extensions will suffer from a
> corrupted stack.
Comment 44 Larry the Git Cow gentoo-dev 2018-03-17 00:17:58 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/proj/kde.git/commit/?id=460ffd9c15ee42497bf7a802d097915b71479dd8

commit 460ffd9c15ee42497bf7a802d097915b71479dd8
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2018-02-25 09:06:06 +0000
Commit:     Michael Palimaka <kensington@gentoo.org>
CommitDate: 2018-03-17 00:17:47 +0000

    cmake-utils.eclass: Extend ASM rules to ASM-ATT
    
    Some CMake projects use ASM-ATT rather than ASM, so extend our rule
    overrides to that.
    
    Closes: https://bugs.gentoo.org/625844

 eclass/cmake-utils.eclass | 3 +++
 1 file changed, 3 insertions(+)
Comment 45 Matt Turner gentoo-dev 2018-03-17 05:45:12 UTC
(In reply to Larry the Git Cow from comment #44)
> The bug has been closed via the following commit(s):
> 
> https://gitweb.gentoo.org/proj/kde.git/commit/
> ?id=460ffd9c15ee42497bf7a802d097915b71479dd8
> 
> commit 460ffd9c15ee42497bf7a802d097915b71479dd8
> Author:     Michał Górny <mgorny@gentoo.org>
> AuthorDate: 2018-02-25 09:06:06 +0000
> Commit:     Michael Palimaka <kensington@gentoo.org>
> CommitDate: 2018-03-17 00:17:47 +0000
> 
>     cmake-utils.eclass: Extend ASM rules to ASM-ATT
>     
>     Some CMake projects use ASM-ATT rather than ASM, so extend our rule
>     overrides to that.
>     
>     Closes: https://bugs.gentoo.org/625844
> 
>  eclass/cmake-utils.eclass | 3 +++
>  1 file changed, 3 insertions(+)

This is a commit to the kde repo. Presumably the Closes tag shouldn't trigger the closure of the bug when it's not in the main repo?
Comment 46 Konstantin M 2018-03-19 07:41:48 UTC
(In reply to James Le Cuirot from comment #43)
> Could someone please confirm that my eclass patch from comment #39 works for
> them before I submit it to the mailing list? Pay close attention to the
> configure output. If you see this then it didn't work:
> 

I just emerged media-libs/vulkan-loader-1.0.61.1::gentoo again (without changes after an emerge --sync), and now it did install successfully.
But during both configure phases (32bit and 64bit) I do get the output you are looking for:

-- Found assembler: /usr/bin/x86_64-pc-linux-gnu-gcc
CMake Warning at loader/CMakeLists.txt:120 (message):
  Could not find working x86 GAS assembler
[...]
Comment 47 James Le Cuirot gentoo-dev 2018-03-19 07:54:31 UTC
(In reply to Konstantin M from comment #46)
> (In reply to James Le Cuirot from comment #43)
> > Could someone please confirm that my eclass patch from comment #39 works for
> > them before I submit it to the mailing list? Pay close attention to the
> > configure output. If you see this then it didn't work:
> > 
> 
> I just emerged media-libs/vulkan-loader-1.0.61.1::gentoo again (without
> changes after an emerge --sync), and now it did install successfully.
> But during both configure phases (32bit and 64bit) I do get the output you
> are looking for:

Right but I haven't merged my patch yet. I want someone to test it first. :)
Comment 48 Alexander Tsoy 2018-03-19 16:30:02 UTC
(In reply to James Le Cuirot from comment #39)
> Created attachment 523674 [details, diff] [details, diff]
> eclass patch to add CMAKE_ASM-ATT_LINK_FLAGS

This patch works for me.
Comment 49 Konstantin M 2018-03-21 17:13:39 UTC
(In reply to James Le Cuirot from comment #47)
> Right but I haven't merged my patch yet. I want someone to test it first. :)

Oops, sorry, I didn't look at it thouroughly enough. I retested with the patch applied to /usr/portage/eclass/cmake-utils.eclass and vulkan-loader emerges just fine and doesn't print the warning you were looking for.

Output with patch applied is (for both, 32 and 64bit as far as I can tell):

-- The ASM-ATT compiler identification is GNU
-- Found assembler: /usr/bin/x86_64-pc-linux-gnu-gcc
-- <<< Gentoo configuration >>>
Build type      Gentoo
Install path    /usr
Compiler flags:
C               -march=native -O2 -pipe -std=c99 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -fno-builtin-memcmp -Wimplicit-fallthrough=0 -fvisibility=hidden
C++             -march=native -O2 -pipe -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -fno-builtin-memcmp -Wimplicit-fallthrough=0 -std=c++11 -fno-rtti -fvisibility=hidden
Linker flags:
Executable      -Wl,-O1 -Wl,--as-needed
Module          -Wl,-O1 -Wl,--as-needed
Shared          -Wl,-O1 -Wl,--as-needed

-- Configuring done
-- Generating done
Comment 50 Larry the Git Cow gentoo-dev 2018-03-23 23:41:56 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03a4991d9ae07d5273a73ae4556b5cd1007ab6ff

commit 03a4991d9ae07d5273a73ae4556b5cd1007ab6ff
Author:     James Le Cuirot <chewi@gentoo.org>
AuthorDate: 2018-03-19 21:16:34 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2018-03-23 23:41:47 +0000

    cmake-utils.eclass: Make the new ASM-ATT rules actually work
    
    The previous attempt actually broke ASM in media-libs/vulkan-loader
    entirely so that it fell back to C code. After much experimentation
    and combing through strace output, I found that -x assembler is needed
    to handle non-standard file extentions and linking is done as a
    separate step. CMAKE_ASM-ATT_LINK_FLAGS therefore needs to be defined
    with -nostdlib to avoid errors about undefined main symbols.
    
    Closes: https://bugs.gentoo.org/625844

 eclass/cmake-utils.eclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 51 Larry the Git Cow gentoo-dev 2018-03-24 00:10:03 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/kde.git/commit/?id=f73d21cbe6317ec0baa2858a4ce4ead72dc7b832

commit f73d21cbe6317ec0baa2858a4ce4ead72dc7b832
Author:     James Le Cuirot <chewi@gentoo.org>
AuthorDate: 2018-03-19 21:16:34 +0000
Commit:     Michael Palimaka <kensington@gentoo.org>
CommitDate: 2018-03-24 00:09:54 +0000

    cmake-utils.eclass: Make the new ASM-ATT rules actually work
    
    The previous attempt actually broke ASM in media-libs/vulkan-loader
    entirely so that it fell back to C code. After much experimentation
    and combing through strace output, I found that -x assembler is needed
    to handle non-standard file extentions and linking is done as a
    separate step. CMAKE_ASM-ATT_LINK_FLAGS therefore needs to be defined
    with -nostdlib to avoid errors about undefined main symbols.
    
    Bug: https://bugs.gentoo.org/625844

 eclass/cmake-utils.eclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)}