Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asm impossible constraint #3

Closed
juliandroid opened this issue Jan 30, 2016 · 5 comments
Closed

asm impossible constraint #3

juliandroid opened this issue Jan 30, 2016 · 5 comments

Comments

@juliandroid
Copy link

I get the following error, while running:

$ make
...
make[4]: Entering directory '/home/july/msed/syslinux/gpxe/src' [BUILD] bin/int13.o arch/i386/interface/pcbios/int13.c: In function ‘register_int13_drive’: arch/i386/interface/pcbios/int13.c:469:2: warning: asm operand 0 probably doesn’t match constraints __asm__ __volatile__ ( ^ arch/i386/interface/pcbios/int13.c:469:2: error: impossible constraint in ‘asm’ bin/deps/arch/i386/interface/pcbios/int13.c.d:86: recipe for target 'bin/int13.o' failed make[4]: *** [bin/int13.o] Error 1

My build env is:
$ nasm -v
NASM version 2.11.08 compiled on Mar 24 2015

$ gcc -v
Using built-in specs.

COLLECT_GCC=/usr/bin/gcc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: /build/gcc-multilib/src/gcc-5.3.0/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release

Thread model: posix

gcc version 5.3.0 (GCC)

$ make -v

GNU Make 4.1

Built for x86_64-unknown-linux-gnu

$ uname -a

Linux stoffle 4.3.3-3-ARCH #1 SMP PREEMPT Wed Jan 20 08:12:23 CET 2016 x86_64 GNU/Linux

I'm running Arch Linux, so all the tools are the latest versions of respective tools.

I'm not an expert of asm constraints, but I did a couple of changes in order to complete the make process (see the patch file). I assume, those changes might be wrong (EDIT: are wrong - see my next comment).
asm_constraints.patch.zip

Regards,
Julian

@juliandroid
Copy link
Author

Ok, I figured it out.
The gcc 5.3.0 (in Arch Linux at least) by default builds position-independent code.
The fix for my gcc is:

diff --git gpxe/src/Makefile.housekeeping gpxe/src/Makefile.housekeeping
index 1f5e115..296ebcf 100644
--- gpxe/src/Makefile.housekeeping
+++ gpxe/src/Makefile.housekeeping
@@ -337,6 +337,7 @@ CFLAGS              += -g
 ifeq ($(CCTYPE),gcc)
 CFLAGS         += -ffreestanding
 CFLAGS         += -Wall -W -Wformat-nonliteral
+CFLAGS         += -fno-PIE
 endif
 ifeq ($(CCTYPE),icc)
 CFLAGS         += -fno-builtin

The gcc compiler should be tested for -fno-PIE option and if it does support it then should be passed as an extra CFLAG option.

@r0m30
Copy link
Contributor

r0m30 commented Feb 4, 2016

That is an upstream change to the syslinux code base that is used for the biospba. I haven't looked at the sysllinux repo in a while so it may already be there. It might be a good thing to send this to them they are at www.syslinux.org.

@r0m30 r0m30 closed this as completed Feb 4, 2016
@juliandroid
Copy link
Author

Yes, I did that.

My suggestion is to fix the Makefile with code that looks something like that:

diff --git gpxe/src/arch/i386/Makefile gpxe/src/arch/i386/Makefile
index dd8da80..5133bd9 100644
--- gpxe/src/arch/i386/Makefile
+++ gpxe/src/arch/i386/Makefile
@@ -67,6 +67,10 @@ CFLAGS       += -fshort-wchar
 #
 CFLAGS         += -Ui386

+GCC_HAS_NO_PIE = [ -z "`$(CC) -fno-PIE -x c -c /dev/null -o /dev/null 2>&1`" ]
+NO_PIE_FLAG := $(shell $(GCC_HAS_NO_PIE) && $(ECHO) '-fno-PIE')
+CFLAGS += $(NO_PIE_FLAG)
+
 # Locations of utilities
 #
 ISOLINUX_BIN   = /usr/lib/syslinux/isolinux.bin

I'm attaching my patch here in case someone else face the same hurdle while building syslinux. Be aware this patch is for their git repository not for this one - i.e. the patch may need to be applied manually.

@r0m30
Copy link
Contributor

r0m30 commented Feb 4, 2016

Great, thanks.

@LITTENg
Copy link

LITTENg commented Sep 10, 2019

@juliandroid Great thanks, this patch really help me a lot.

clrpackages pushed a commit to clearlinux-pkgs/syslinux that referenced this issue Oct 9, 2019
Add no-PIE CFLAG to fix build error "impossible constraint in 'asm'" in int13.c.
Refered Drive-Trust-Alliance/syslinux#3

Signed-off-by: Brandon Hong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants