[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#870375: gcc-7: Native gdc cross-builds fail



impcvgen is to be ran on the host, so it should be using the host
compiler to compile both object and resultant executable.

Having a look, I'm just recycling $(COMPILE) here.  This is probably
wrong, as $(ALL_COMPILERFLAGS) may be different to
$(BUILD_COMPILERFLAGS) - or least I can only assume that must be the
case here.

Do you have available the command that was ran to compile d/impcnvgen.dmdgen.o?

My tentative patch - explicitly use BUILD_XXX vars to build the .o
file.  It already uses $(LINKER_FOR_BUILD) to produce the executable.

diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index f0319cb9..e528b191 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -51,7 +51,7 @@ d-warn = $(filter-out -pedantic
-Woverloaded-virtual, $(STRICT_WARN))
 # D Frontend has slightly relaxed warnings compared to rest of GDC.
 DMD_WARN_CXXFLAGS = -Wno-deprecated -Wstrict-aliasing -Wuninitialized
 DMD_COMPILE = $(subst $(WARN_CXXFLAGS), $(DMD_WARN_CXXFLAGS), $(COMPILE))
-DMDGEN_COMPILE = $(subst $(COMPILER), $(COMPILER_FOR_BUILD), $(DMD_COMPILE))
+DMDGEN_COMPILERFLAGS = $(subst $(WARN_CXXFLAGS),
$(DMD_WARN_CXXFLAGS), $(BUILD_COMPILERFLAGS))

 # D Frontend object files.
 D_FRONTEND_OBJS = \
@@ -270,5 +270,5 @@ d/verstr.h: d/VERSION
        cat $^ > $@

 d/%.dmdgen.o: $(srcdir)/d/dfrontend/%.c
-       $(DMDGEN_COMPILE) $(D_INCLUDES) $<
-       $(POSTCOMPILE)
+       $(COMPILER_FOR_BUILD) -c $(DMDGEN_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
+               -o $@ $<


On 12 September 2017 at 21:34, Matthias Klose <doko@debian.org> wrote:
> Control: tags -1 - patch
>
> no, not a patch, but a hack.
>
> Iain, is the wrong compiler called for that?
>
> On 01.08.2017 15:39, John Paul Adrian Glaubitz wrote:
>> Source: gcc-7
>> Version: 7.1.0-11
>> Severity: normal
>> Tags: patch
>>
>> Hi!
>>
>> Trying to do a cross-native build for m68k with gdc enabled fails with:
>>
>> g++    -o d/impcvgen d/impcnvgen.dmdgen.o
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> /usr/bin/ld: d/idgen.dmdgen.o: Relocations in generic ELF (EM: 4)
>> d/idgen.dmdgen.o: error adding symbols: File in wrong format
>> collect2: error: ld returned 1 exit status
>> ../../src/gcc/d/Make-lang.in:254: recipe for target 'd/idgen' failed
>>
>> I'm currently working around this issue by adding the following
>> changes to debian/rules.defs:
>>
>> --- debian/rules.defs.orig      2017-08-01 15:35:52.999394076 +0200
>> +++ debian/rules.defs   2017-08-01 15:27:13.531269664 +0200
>> @@ -869,6 +869,9 @@
>>  ifeq ($(DEB_STAGE)-$(filter libphobos, $(with_rtlibs)),rtlibs-)
>>    with_d := disabled for rtlibs stage
>>  endif
>> +ifeq (,$(filter $(build_type), build-cross build-native))
>> +   with_d += no
>> +endif
>>  with_d := $(call envfilt, d, , , $(with_d))
>>
>>  #with_d := not yet built for GCC 7
>>
>> I'm attaching the patch just in case. I will also test whether this
>> affects other architectures for cross-native builds.
>>
>> Adrian
>>
>> --
>>  .''`.  John Paul Adrian Glaubitz
>> : :' :  Debian Developer - glaubitz@debian.org
>> `. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
>>   `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
>>
>


Reply to: