public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] cmake-utils.eclass: Make the new ASM-ATT rules actually work
@ 2018-03-19 21:16 James Le Cuirot
  2018-03-19 22:16 ` Matt Turner
  0 siblings, 1 reply; 4+ messages in thread
From: James Le Cuirot @ 2018-03-19 21:16 UTC (permalink / raw)
  To: gentoo-dev; +Cc: James Le Cuirot

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
---
One user has confirmed that this patch works for vulkan-loader and I'd
like a dev or two to also confirm this before I merge.

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

diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
index f8853be502a1..f6952ec09efd 100644
--- a/eclass/cmake-utils.eclass
+++ b/eclass/cmake-utils.eclass
@@ -520,7 +520,8 @@ cmake-utils_src_configure() {
 	fi
 	cat > "${build_rules}" <<- _EOF_ || die
 		SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
-		SET (CMAKE_ASM-ATT_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
+		SET (CMAKE_ASM-ATT_COMPILE_OBJECT "<CMAKE_ASM-ATT_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c -x assembler <SOURCE>" CACHE STRING "ASM-ATT compile command" FORCE)
+		SET (CMAKE_ASM-ATT_LINK_FLAGS "-nostdlib" CACHE STRING "ASM-ATT link flags" FORCE)
 		SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
 		SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
 		SET (CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> <DEFINES> ${includes} ${FCFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "Fortran compile command" FORCE)
-- 
2.16.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] cmake-utils.eclass: Make the new ASM-ATT rules actually work
  2018-03-19 21:16 [gentoo-dev] [PATCH] cmake-utils.eclass: Make the new ASM-ATT rules actually work James Le Cuirot
@ 2018-03-19 22:16 ` Matt Turner
  2018-03-19 22:40   ` James Le Cuirot
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Turner @ 2018-03-19 22:16 UTC (permalink / raw)
  To: gentoo development; +Cc: James Le Cuirot

Thanks for looking into this!

I'm not sure I understand the -nostdlib portion. It's something about
working around a side-effect of -x assembler?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] cmake-utils.eclass: Make the new ASM-ATT rules actually work
  2018-03-19 22:16 ` Matt Turner
@ 2018-03-19 22:40   ` James Le Cuirot
  2018-03-23 23:43     ` Matt Turner
  0 siblings, 1 reply; 4+ messages in thread
From: James Le Cuirot @ 2018-03-19 22:40 UTC (permalink / raw)
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

On Mon, 19 Mar 2018 15:16:47 -0700
Matt Turner <mattst88@gentoo.org> wrote:

> Thanks for looking into this!
> 
> I'm not sure I understand the -nostdlib portion. It's something about
> working around a side-effect of -x assembler?

It's not related to that option. I think it's because this is normally
built with "as" and "ld" and by using "gcc" instead, it tries to link
libc and friends, which otherwise wouldn't happen. It'll fail if you
take it away and you'll find the error if you dig through tons of
strace. Strangely you don't see the linking command in the regular
build output.

-- 
James Le Cuirot (chewi)
Gentoo Linux Developer

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 981 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] cmake-utils.eclass: Make the new ASM-ATT rules actually work
  2018-03-19 22:40   ` James Le Cuirot
@ 2018-03-23 23:43     ` Matt Turner
  0 siblings, 0 replies; 4+ messages in thread
From: Matt Turner @ 2018-03-23 23:43 UTC (permalink / raw)
  To: gentoo development

On Mon, Mar 19, 2018 at 3:40 PM, James Le Cuirot <chewi@gentoo.org> wrote:
> On Mon, 19 Mar 2018 15:16:47 -0700
> Matt Turner <mattst88@gentoo.org> wrote:
>
>> Thanks for looking into this!
>>
>> I'm not sure I understand the -nostdlib portion. It's something about
>> working around a side-effect of -x assembler?
>
> It's not related to that option. I think it's because this is normally
> built with "as" and "ld" and by using "gcc" instead, it tries to link
> libc and friends, which otherwise wouldn't happen. It'll fail if you
> take it away and you'll find the error if you dig through tons of
> strace. Strangely you don't see the linking command in the regular
> build output.

I finally got around to testing this, and it works like a charm.
Thanks a bunch, and thanks for the upstream fix as well.

I just pushed it -- finally that pesky bug 625844 is fixed after 9 months :)

Thanks to mgorny for his work on it too!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-23 23:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 21:16 [gentoo-dev] [PATCH] cmake-utils.eclass: Make the new ASM-ATT rules actually work James Le Cuirot
2018-03-19 22:16 ` Matt Turner
2018-03-19 22:40   ` James Le Cuirot
2018-03-23 23:43     ` Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox