Skip to content

Commit 0e07d65

Browse files
committed
os: Add userspace Makefile
Add a new userspace Makefile to build userspace object file and clean it. For app binary we need up_userspace.o, and for common binary we need up_userspace_common.o. So split build targets into app_obj and common_obj to support each binary. When we build loadable apps, userspace.o is built but not cleaned. This can make linking error between other boards. This patch fix this issue by adding userspace Makefile. [Linking Error] ``` make[1]: Leaving directory '/root/tizenrt/os/binfmt' make[1]: Entering directory '/root/tizenrt/loadable_apps' make[2]: Entering directory '/root/tizenrt/loadable_apps/loadable_sample/wifiapp' CC: wifiapp.c arm-none-eabi-ld: error: /root/tizenrt/os/../build/output/bin/app1.relelf uses VFP register arguments, /root/tizenrt/os/userspace/up_userspace.o does not arm-none-eabi-ld: error: /root/tizenrt/os/userspace/up_userspace.o: conflicting CPU architectures 14/17 arm-none-eabi-ld: failed to merge target specific data of file /root/tizenrt/os/userspace/up_userspace.o /root/tizenrt/os/../loadable_apps/loadable.mk:66: recipe for target 'undefsym' failed make[2]: Leaving directory '/root/tizenrt/loadable_apps/loadable_sample/wifiapp' make[2]: *** [undefsym] Error 1 Makefile:71: recipe for target 'loadable_sample/wifiapp_undefsym' failed make[1]: Leaving directory '/root/tizenrt/loadable_apps' make[1]: *** [loadable_sample/wifiapp_undefsym] Error 2 make: *** [pass1] Error 2 Makefile.unix:458: recipe for target 'pass1' failed ``` Signed-off-by: seokhun-eom <seokhun.eom@samsung.com>
1 parent c0882aa commit 0e07d65

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

loadable_apps/loadable.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ OBJCOPY = $(CROSSDEV)objcopy
3333

3434
APPDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __APP_BUILD__}
3535

36-
SRCS += $(USERSPACE).c
37-
38-
OBJS = $(SRCS:.c=$(OBJEXT))
36+
OBJS = $(SRCS:.c=$(OBJEXT)) $(USERSPACE)$(OBJEXT)
3937

4038
prebuild:
4139
$(call DELFILE, $(USERSPACE)$(OBJEXT))
4240

4341
all: prebuild postbuild
4442
.PHONY: prebuild postbuild clean install distclean
4543

44+
$(USERSPACE)$(OBJEXT):
45+
$(Q) $(MAKE) -C $(TOPDIR)/userspace TOPDIR="$(TOPDIR)" APPDEFINE="$(APPDEFINE)" CELFFLAGS="$(CELFFLAGS)" app_obj
46+
4647
$(OBJS): %$(OBJEXT): %.c
4748
@echo "CC: $<"
4849
$(Q) $(CC) $(APPDEFINE) -c $(CELFFLAGS) $< -o $@

os/Directories.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,5 @@ CLEANDIRS += se
277277
ifeq ($(CONFIG_NDP120),y)
278278
CONTEXTDIRS += drivers
279279
endif
280+
281+
CLEANDIRS += userspace

os/Makefile.unix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ ifeq ($(CONFIG_ELF),y)
456456
$(Q) $(LD) -r -o $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME) -T $(TOPDIR)/userspace/userspace_apps.ld -L $(LIBRARIES_DIR) --start-group $(USERLIBS) $(LIBGCC) $(LIBSUPXX) --end-group $$(cat $(OUTBIN_DIR)/lib_symbols.txt)
457457
else
458458
$(Q) $(TOPDIR)/tools/mkldscript.py
459-
$(Q) $(CC) -c $(CFLAGS) -D__COMMON_BINARY__ $(TOPDIR)/userspace/up_userspace.c -o $(TOPDIR)/userspace/up_userspace_common.o
459+
$(Q) $(MAKE) -C userspace CFLAGS="$(CFLAGS)" TOPDIR="$(TOPDIR)" common_obj
460460
ifneq ($(CONFIG_XIP_ELF_WARCHIVE), y)
461461
$(Q) $(MAKE) -C $(LOADABLE_APPDIR) TOPDIR="$(TOPDIR)" LOADABLEDIR="${LOADABLE_APPDIR}" LIBRARIES_DIR="$(LIBRARIES_DIR)" USERLIBS="$(USERLIBS)" undefsym KERNEL=n
462462
$(Q) $(LD) -o $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME) -T $(OUTBIN_DIR)/common_0.ld -T $(TOPDIR)/../build/configs/$(CONFIG_ARCH_BOARD)/scripts/xipelf/userspace_all.ld $(TOPDIR)/userspace/up_userspace_common.o -L $(LIBRARIES_DIR) --start-group $(USERLIBS) $(LIBGCC) $(LIBSUPXX) --end-group $$(cat $(OUTBIN_DIR)/lib_symbols.txt) -Map $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME).map

os/userspace/Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
###########################################################################
2+
#
3+
# Copyright 2026 Samsung Electronics All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14+
# either express or implied. See the License for the specific
15+
# language governing permissions and limitations under the License.
16+
#
17+
###########################################################################
18+
19+
-include $(TOPDIR)/Make.defs
20+
21+
APP_OBJ = up_userspace$(OBJEXT)
22+
COMMON_OBJ = up_userspace_common$(OBJEXT)
23+
24+
all: app_obj
25+
.PHONY: all app_obj common_obj clean distclean
26+
27+
app_obj: $(APP_OBJ)
28+
29+
common_obj: $(COMMON_OBJ)
30+
31+
$(APP_OBJ): up_userspace.c
32+
$(Q) $(CC) $(APPDEFINE) -c $(CELFFLAGS) $< -o $@
33+
34+
$(COMMON_OBJ): up_userspace.c
35+
$(Q) $(CC) -c $(CFLAGS) -D__COMMON_BINARY__ $< -o $@
36+
37+
clean:
38+
$(call DELFILE, $(APP_OBJ))
39+
$(call DELFILE, $(COMMON_OBJ))
40+
$(call CLEAN)
41+
42+
distclean: clean

0 commit comments

Comments
 (0)