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

Fixes issues found when compiling for fvm with gcc #154

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions assets/flipper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ all:: $(HOST_TARGET)
endif

# Target when building for the Flipper Virtual Machine
fvm: $(FVM_TARGET)
fvm:: $(FVM_TARGET)

ifeq ($(HOST_SRCS), )
else
fvm:: $(HOST_TARGET)
endif


echo[%]:
@echo 'Variable "$*" = "$($*)"'
Expand Down Expand Up @@ -110,21 +116,30 @@ $(HOST_BUILD)/%.c.o: %.c | $(HOST_BUILD_DIRS)
$(HOST_GLUE_TARGET): $(HOST_GLUE_OBJS)
$(HOST_AR) -rcs $@ $^

$(HOST_TARGET): $(HOST_BUILD)/$(MODULE).a $(HOST_OBJS)
$(HOST_LD) $(HOST_LDFLAGS) -lflipper -o $@ $^
$(HOST_TARGET): $(HOST_OBJS) $(HOST_BUILD)/$(MODULE).a
$(HOST_LD) $(HOST_LDFLAGS) -o $@ $^ -lflipper

# Keep track of #include dependencies for incremental builds
-include $(HOST_DEPS)

# FVM build targets
$(FVM_BUILD)/cbind.c.o: $(FVM_BUILD)/cbind.c | $(FVM_BUILD_DIRS)
$(FVM_CC) $(FVM_CFLAGS) -fPIC -MD -MP -MF $(FVM_BUILD)/$*.c.d -c -o $@ $<

$(FVM_BUILD)/%.c.o: %.c | $(FVM_BUILD_DIRS)
$(FVM_CC) $(FVM_CFLAGS) -MD -MP -MF $(FVM_BUILD)/$*.c.d -c -o $@ $<

$(FVM_BUILD)/package_data.c: | $(FVM_BUILD_DIRS)
echo "unsigned char package_bin[] = {\n};\nunsigned package_bin_len = 0;" > $@
$(FVM_BUILD)/package_data.c: $(FLIPPER_TARGET) | $(HOST_BUILD_DIRS)
(cd $(<D) && xxd -i $(<F)) > $@

$(FVM_BUILD)/cbind.c: $(FVM_BUILD)/main.elf
fdwarf $< $(MODULE) c $(FVM_BUILD)/cbind.c

$(FVM_BUILD)/main.elf: $(FVM_OBJS)
$(FVM_LD) $(FVM_LDFLAGS) -shared -o $@ $^ -lflipper

$(FVM_TARGET): $(FVM_OBJS)
$(FVM_LD) $(FVM_LDFLAGS) -shared -lflipper -o $@ $^
$(FVM_TARGET): $(FVM_OBJS) $(FVM_BUILD)/cbind.c.o
$(FVM_LD) $(FVM_LDFLAGS) -shared -o $@ $^ -lflipper

# Keep track of #include dependencies for incremental builds
-include $(FVM_DEPS)
Expand Down
1 change: 1 addition & 0 deletions carbon/include/flipper/carbon.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <flipper/atmegau2/atmegau2.h>
#elif defined(POSIX)
#include <flipper/posix/posix.h>
#include <flipper/atsam4s/asf/pio/pio_sam4s16b.h>
#else
#error "Invalid target platform."
#endif
Expand Down
5 changes: 5 additions & 0 deletions library/include/flipper/posix/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@
#define __use_wdt__

/* Declare the LF_VAR and LF_FUNC types for this platform. */
#ifdef __clang__
#define LF_VAR __attribute__((section("__DATA,.lf.vars")))
#define LF_FUNC __attribute__((section("__TEXT,.lf.funcs")))
#else
#define LF_VAR __attribute__((section(".lf.vars")))
#define LF_FUNC __attribute__((section(".lf.funcs")))
#endif

#else
#error "Error: Multiple platforms targeted."
Expand Down