Bug 46405 - potrace: ошибка сборки на не-x86 архитектурах
Summary: potrace: ошибка сборки на не-x86 архитектурах
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: potrace (show other bugs)
Version: unstable
Hardware: all Linux
: P5 normal
Assignee: Yuri N. Sedunov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-06 16:23 MSK by Alexey Sheplyakov
Modified: 2023-08-31 15:58 MSK (History)
4 users (show)

See Also:


Attachments
исправление проблемы (2.43 KB, patch)
2023-06-06 17:00 MSK, Alexey Sheplyakov
no flags Details | Diff
таки исправление проблемы (2.70 KB, patch)
2023-06-06 17:41 MSK, Alexey Sheplyakov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Sheplyakov 2023-06-06 16:23:49 MSK
libtool: compile:  loongarch64-alt-linux-gcc -DHAVE_CONFIG_H -I. -I.. -pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -c trace.c  -fPIC -DPIC -o .libs/trace.o
make[2]: Leaving directory '/usr/src/RPM/BUILD/potrace-1.16/src'
make[2]: Entering directory '/usr/src/RPM/BUILD/potrace-1.16/src'
/bin/sh ../libtool  --tag=CC   --mode=link loongarch64-alt-linux-gcc  -pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto   -o mkbitmap mkbitmap.o bitmap_io.o greymap.o -lm
libtool: link: loongarch64-alt-linux-gcc -pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -o mkbitmap mkbitmap.o bitmap_io.o greymap.o  -lm
{standard input}: Assembler messages:
{standard input}:3817: Error: no match insn: bsf        $r12,$r14
{standard input}:3818: Error: no match insn: jnz        0f
{standard input}:3819: Error: no match insn: movl       $32,$r14
{standard input}:3839: Error: no match insn: bsf        $r12,$r13
{standard input}:3840: Error: no match insn: jnz        0f
{standard input}:3841: Error: no match insn: movl       $32,$r13
{standard input}:3852: Error: no match insn: bsf        $r12,$r12
{standard input}:3853: Error: no match insn: jnz        0f
{standard input}:3854: Error: no match insn: movl       $32,$r12
make[3]: *** [/usr/src/tmp/cckhtRVf.mk:2: /usr/src/tmp/ccI17jqP.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status


При этом в выводе configure скрипта

checking for uint64_t... yes
checking for getopt_long... yes
checking whether getopt_long reorders its arguments... yes
checking whether to use included getopt... no
checking for strcasecmp... yes
checking for strncasecmp... yes
checking for Intel 386... yes
Comment 1 Alexey Sheplyakov 2023-06-06 16:48:10 MSK
Вот тестовая программа, с помощью которой configure проверяет, можно ли использовать x86 ассемблер:

int main() {
   int x;
   asm("bsf %1,%0\njnz 0f\nmovl $32,%0\n0:":"=r"(x):"r"(x));
   return x;
}

Обычно при обработке директивы asm компилятор обрабатывает только ограничения на регистры (constraints) (ну и clobbers), а то, что в двойных кавычках, скармливает ассемблеру.

Но данная программа содержит неопределённое поведение (undefined behavior), а именно чтение неинициализированной переменной x. Поэтому оптимизатор решает просто выбросить всю эту строчку. По-простому говоря - какая разница, какой именно мусор вернёт main, можно вернуть просто то, что изначально было в x. То есть преобразует этот тест в

int main() { int x; return x; }

Никаких инструкций, специфичных для x86, здесь не остаётся, так что тест успешно собирается на любой архитектуре, где осмыслены ограничения  "=r", "r" (то есть чуть менее, чем везде).
Comment 2 Alexey Sheplyakov 2023-06-06 16:59:13 MSK
Сразу отвечу на вопрос -- "а как же пакет раньше собирался?". Крайний раз его пересобирали до того, как в добровольно-принудительном порядке внедрили LTO.
Comment 3 Alexey Sheplyakov 2023-06-06 17:00:01 MSK
Created attachment 13393 [details]
исправление проблемы
Comment 4 Alexey Sheplyakov 2023-06-06 17:41:46 MSK
Created attachment 13394 [details]
таки исправление проблемы
Comment 5 Alexey Sheplyakov 2023-06-06 17:43:20 MSK
(Ответ для Alexey Sheplyakov на комментарий #4)
> Создано вложение 13394 [details] [подробности]
> таки исправление проблемы

Чтобы LTO не выпилил asm (даже вполне корректный), понадобилось пометить volatile и добавить "memory" clobber.
Comment 6 Repository Robot 2023-08-31 15:58:32 MSK
potrace-1.16-alt2 -> sisyphus:

 Tue Jun 06 2023 Alexey Sheplyakov <asheplyakov@altlinux> 1.16-alt2
 - Fixed compilation error on non-x86 architectures (closes: #46405)