使用"cc"而不是“无臂eabi-as" [英] make uses "cc" instead of "arm-none-eabi-as"

查看:39
本文介绍了使用"cc"而不是“无臂eabi-as"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用makefile构建程序时出现问题.当make尝试编译名为"startup.S"的程序集文件时,只有一个问题.即使我在makefile中指定"arm-none-eabi-as",make仍使用make编译器"cc"(请看变量AS).

I have a problem when building a program with makefile. There is only a problem when make tries to compile assembly file named "startup.S". It looks like make uses compiler "cc" even if i specify "arm-none-eabi-as" in a makefile (take a look at variable AS).

这是我的makefile:

Here is my makefile:

SHELL := /bin/bash
ROOT := $(shell pwd)
INC := $(ROOT)/inc
SRC := $(ROOT)/src
STR := $(ROOT)/str
EXE := exe
AS := arm-none-eabi-as -mcpu=arm926ej-s -c -Wall -I $(INC) -I$(SRC) -I $(STR)
GCC := arm-none-eabi-gcc -mcpu=arm926ej-s -c -Wall -I $(INC) -I$(SRC) -I $(STR)
LDSCRIPT := test.ld
LD := arm-none-eabi-ld -T $(LDSCRIPT)
HEADERS := $(notdir $(wildcard $(INC)/*.h))
SOURCES_GCC := $(notdir $(wildcard $(SRC)/*.c))
SOURCES_AS := $(notdir $(wildcard $(STR)/*.S))
OBJECTS_GCC := $(SOURCES_GCC:.c=.o)
OBJECTS_AS := $(SOURCES_AS:.S=.o)
VPATH := $(STR):$(SRC):$(INC)

all : $(EXE)
    @echo konec postopka: izvrsljiv program po imenu $(EXE) se nahaja v mapi $(ROOT)
$(EXE) : $(OBJECTS_AS) $(OBJECTS_GCC)
    @echo objekti so: $(OBJECTS_AS) $(OBJECTS_GCC)
    @echo headerji so: $(HEADERS)
    @echo linkanje objektov v izvrsljiv program...
    $(LD) -o $@ $^
%.o : %.S %h
    @echo prevajanje ASSEMBLY izvornih datotek...
    $(AS) -o $@  $<
%.o : %.c %h
    @echo prevajanje C izvornih datotek...
    $(GCC) -o $@ $<
.PHONY : clean
clean :
    @echo brisanje objektov
    rm *.o
    @echo brisanje izvrsljivega programa
    rm $(EXE)

这是我在终端中键入comand make时遇到的错误.它清楚地表明"cc"不理解汇编语言,并且一定会出现此错误.

Here is the error i get when typing comand make in a terminal. It clearly tells that "cc" doesnt understand assembly language, and this error is somewhat expected.

cc    -c -o startup.o /home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S: Assembler messages:
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:4: Error: no such instruction: `b Reset_Handler'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:5: Error: no such instruction: `b .'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:6: Error: no such instruction: `b .'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:7: Error: no such instruction: `b .'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:8: Error: no such instruction: `b .'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:9: Error: no such instruction: `b .'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:10: Error: no such instruction: `b .'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:11: Error: no such instruction: `b .'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:14: Error: no such instruction: `ldr sp,=stack_top'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:15: Error: no such instruction: `bl c_entry'
/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/makefile_8/str/startup.S:16: Error: no such instruction: `b .'

如果我尝试使用"arm-none-eabi-as startup.S"手动进行编译,它会很好...

If i try to compile it manualy using "arm-none-eabi-as startup.S" it compiles fine...

我的问题是,为什么make使用cc代替arm-none-eabi-as?我在这里想念什么?

在您完成所有提案后,我设法制作了一个makefile,看起来像这样,并且可以正常工作:

After all of your proposal i managed to make a makefile, that looks like this and it is working:

SHELL := /bin/bash
ROOT := $(shell pwd)
INC := $(ROOT)/inc
SRC := $(ROOT)/src
STR := $(ROOT)/str
EXE := exe
AS := arm-none-eabi-as -mcpu=arm926ej-s -c -Wall -I $(INC) -I$(SRC) -I $(STR)
CC := arm-none-eabi-gcc -mcpu=arm926ej-s -c -Wall -I $(INC) -I$(SRC) -I $(STR)
LDSCRIPT := ldscript_iram_gnu.ld
LD := arm-none-eabi-ld -T $(LDSCRIPT)
HEADERS := $(notdir $(wildcard $(INC)/*.h))
SOURCES_CC := $(notdir $(wildcard $(SRC)/*.c))
SOURCES_AS := $(notdir $(wildcard $(STR)/*.S))
OBJECTS_CC := $(SOURCES_CC:.c=.o)
OBJECTS_AS := $(SOURCES_AS:.S=.o)
VPATH := $(STR):$(SRC):$(INC)

all : $(EXE)
    @echo konec postopka: izvrsljiv program po imenu $(EXE) se nahaja v mapi $(ROOT)
$(EXE) : $(OBJECTS_AS) $(OBJECTS_CC)
    @echo objekti so: $(OBJECTS_AS) $(OBJECTS_CC)
    @echo headerji so: $(HEADERS)
    @echo linkanje objektov v izvrsljiv program...
    $(LD) -o $@ $^
%.o : %.S
    @echo prevajanje ASSEMBLY izvornih datotek...
    $(AS) -o $@  $<
%.o : %.h

%.o : %.c
    @echo prevajanje C izvornih datotek...
    $(CC) -o $@ $<
%.o : %.h

.PHONY : clean
clean :
    @echo brisanje objektov
    rm *.So
    rm *.o
    @echo brisanje izvrsljivega programa
    rm $(EXE)

当我尝试在其他项目(从一开始就为我的makefile创建的项目)中使用相同的makefile时,该项目也具有相同的树结构,我会遇到一些错误:

When i tried to use same makefile in other project (project for which my makefile has been built from the beginning) which also has same tree structure i get some errors:

make all 
objekti so: timer_example.o
headerji so: ea3131_board.h ffconf.h ff.h integer.h lpc313x_cgu_driver.h lpc313x_cgu.h lpc313x_cgu_switchbox.h lpc313x_chip.h lpc313x_crc_driver.h lpc313x_dmac.h lpc313x_dma_driver.h lpc313x_evt_driver.h lpc313x_evt_router.h lpc313x_i2c_driver.h lpc313x_i2c.h lpc313x_intc_driver.h lpc313x_intc.h lpc313x_ioconf_driver.h lpc313x_ioconf.h lpc313x_mci_driver.h lpc313x_mci.h lpc313x_nandc.h lpc313x_nand_driver.h lpc313x_spi_driver.h lpc313x_spi.h lpc313x_sysreg.h lpc313x_timer_driver.h lpc313x_timer.h lpc313x_uart_driver.h lpc313x_uart.h lpc313x_wdt_driver.h lpc313x_wdt.h lpc31xx_vmem_driver.h lpc_api.h lpc_arm922t_arch.h lpc_arm922t_cp15_driver.h lpc_arm_arch.h lpc_bmp.h lpc_colors.h lpc_fat16.h lpc_fat16_private.h lpc_fonts.h lpc_heap.h lpc_helvr10.h lpc_irq_fiq.h lpc_lbecc.h lpc_lcd_params.h lpc_line_parser.h lpc_nandflash_params.h lpc_params.h lpc_rom8x16.h lpc_rom8x8.h lpc_sdmmc.h lpc_string.h lpc_swim_font.h lpc_swim.h lpc_swim_image.h lpc_types.h lpc_winfreesystem14x16.h lpc_x5x7.h lpc_x6x13.h
linkanje objektov v izvrsljiv program...
arm-none-eabi-ld -T ldscript_iram_gnu.ld -o exe timer_example.o
ea3131_startup_entry.o: In function `clearzi_exit':
(.text+0x170): undefined reference to `ea3131_init'
timer_example.o: In function `timer0_user_interrupt':
timer_example.c:(.text+0x15c): undefined reference to `timer_ioctl'
timer_example.o: In function `uart_string_write':
timer_example.c:(.text+0x1dc): undefined reference to `strlen'
timer_example.c:(.text+0x208): undefined reference to `uart_write'
timer_example.o: In function `c_entry':
timer_example.c:(.text+0x258): undefined reference to `ea3131_board_init'
timer_example.c:(.text+0x260): undefined reference to `cp15_set_vmmu_addr'
timer_example.c:(.text+0x268): undefined reference to `int_initialize'
timer_example.c:(.text+0x274): undefined reference to `int_install_irq_handler'
timer_example.c:(.text+0x280): undefined reference to `timer_open'
timer_example.c:(.text+0x2a4): undefined reference to `timer_ioctl'
timer_example.c:(.text+0x2bc): undefined reference to `timer_ioctl'
timer_example.c:(.text+0x2d4): undefined reference to `timer_ioctl'
timer_example.c:(.text+0x2e0): undefined reference to `uart_open'
timer_example.c:(.text+0x2f8): undefined reference to `memcpy'
timer_example.c:(.text+0x32c): undefined reference to `timer_ioctl'
timer_example.c:(.text+0x334): undefined reference to `int_enable'
timer_example.c:(.text+0x38c): undefined reference to `sprintf'
make: *** [exe] Error 1

在我看来,我的makefile现在运行正常,但是项目中有一些未解析的引用与我的makefile没有关系.仍然需要您确认我的makefile正常运行.谢谢大家.

It looks to me that my makefile is doing OK now, but there are some unresolved references within my project which have nothing to do with my makefile. Still i need your conformation that my makefile is doing OK. Thank you all.

致谢.

推荐答案

尝试使用CC代替GCC(这是默认make规则中使用的变量),但是在这种情况下,它发现了另一个问题:您的规则被忽略了

Try using CC instead of GCC (which is the variable used in the default make rules), but in this case, it uncovered another issue: your rules were ignored.

%h"应该做什么?

还请注意,您的"echo"命令未执行-另一个提示表明make不会考虑您的规则

Also note that your "echo" command isn't executed - another hint that your rules aren't considered by make

这篇关于使用"cc"而不是“无臂eabi-as"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆