ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: devel@lists.altlinux.org
Subject: Re: [devel] story time: LTO vs weird configure.ac
Date: Wed, 14 Sep 2022 15:20:32 +0300
Message-ID: <20220914122031.GA26760@altlinux.org> (raw)
In-Reply-To: <20220914111752.67she5b46vzksvvf@titan.localdomain>

On Wed, Sep 14, 2022 at 03:17:52PM +0400, Ivan A. Melnikov wrote:
> Привет.
> 
> Хочу поделиться ещё одной любопытной историей.
> 
> Для обновления boost мне понадобилось пересобрать пакет taler,
> однако он отказался пересобираться на aarch64 и ppc64le
> c интересной диагностикой:
> 
>   secp256k1/src/scalar_4x64_impl.h:748:5: error: unknown register name 'rdx' in 'asm'
>   secp256k1/src/scalar_4x64_impl.h:748:5: error: unknown register name 'rax' in 'asm'
> 
> и дальше в таком духе.
> 
> Оказалось, что configure этого чуда в вопросах включения
> ассемблерных вставок не ориентируется на текущую платформу,
> а просто проверяет, что ассембелрные вставки, совместимые
> с x86_64, работают, для чего компилирует ($CC -c ...)
> такую вот бесхитростную программу:
> 
> $ cat conftest.c
> 
>   #include <stdint.h>
> int
> main ()
> {
> 
>   uint64_t a = 11, tmp;
>   __asm__ __volatile__("movq \$0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
> 
>   ;
>   return 0;
> }
> 
> 
> Естественно, это чудо не компилируется, например, на aarch64:
> 
> $ aarch64-linux-gnu-gcc -c conftest.c
> conftest.c: In function 'main':
> conftest.c:8:60: warning: unknown escape sequence: '\$'
>     8 |   __asm__ __volatile__("movq \$0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
>       |                                                            ^
> conftest.c:8:3: error: unknown register name '%rdx' in 'asm'
>     8 |   __asm__ __volatile__("movq \$0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
>       |   ^~~~~~~
> 
> 
> Однако с -flto=auto, прилетающего из %optfags, компилируется:
> 
> $ aarch64-linux-gnu-gcc -c -flto=auto  conftest.c
> conftest.c: In function 'main':
> conftest.c:8:60: warning: unknown escape sequence: '\$'
>     8 |   __asm__ __volatile__("movq \$0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
>       |                                                            ^
> $ echo $?
> 0
> 
> Что, опять же, понятно: при таком LTO содержимое такой
> ассемблерной вставки будет разбирать только ассемблер
> и только на этапе компоновки, внутри lto-шащего плагина ld.
> 
> Замена AC_COMPILE_IFELSE на AC_LINK_IFELSE помогла.

Мне кажется, это уже где-то всплывало, но сейчас не помню, где именно.


-- 
ldv


      reply	other threads:[~2022-09-14 12:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 11:17 Ivan A. Melnikov
2022-09-14 12:20 ` Dmitry V. Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220914122031.GA26760@altlinux.org \
    --to=ldv@altlinux.org \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git