| Summary: | potrace: ошибка сборки на не-x86 архитектурах | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Sisyphus | Reporter: | Alexey Sheplyakov <asheplyakov> | ||||||
| Component: | potrace | Assignee: | Yuri N. Sedunov <aris> | ||||||
| Status: | CLOSED FIXED | QA Contact: | qa-sisyphus | ||||||
| Severity: | normal | ||||||||
| Priority: | P5 | CC: | aris, asheplyakov, iv, sin | ||||||
| Version: | unstable | ||||||||
| Hardware: | all | ||||||||
| OS: | Linux | ||||||||
| Attachments: |
|
||||||||
Вот тестовая программа, с помощью которой 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" (то есть чуть менее, чем везде).
Сразу отвечу на вопрос -- "а как же пакет раньше собирался?". Крайний раз его пересобирали до того, как в добровольно-принудительном порядке внедрили LTO. Created attachment 13393 [details]
исправление проблемы
Created attachment 13394 [details]
таки исправление проблемы
(Ответ для Alexey Sheplyakov на комментарий #4) > Создано вложение 13394 [details] [подробности] > таки исправление проблемы Чтобы LTO не выпилил asm (даже вполне корректный), понадобилось пометить volatile и добавить "memory" clobber. |
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