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

libc_bypass: Move libc nuttx from apps to frameworks #3

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
3 changes: 3 additions & 0 deletions libc_bypass/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syscall_glue.c
libc_glue.c
libm_glue.c
36 changes: 36 additions & 0 deletions libc_bypass/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright (C) 2024 Xiaomi Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

config WASM_LIBC_BYPASS
bool "Enable bypass libc to use NuttX system calls"
default n
---help---
Bypass libc to use NuttX system calls

If this option is enabled, the libc will be bypassed and the NuttX
system calls will be used directly. This only works with bounds check
disabled.

if WASM_LIBC_BYPASS

config LIBC_BYPASS_POSIXMEMALIGN_MAP_SIZE
int "Set the size for posix_memalign mapping"
default 64
---help---
This option sets the size for the posix_memalign mapping when
bypassing libc to use NuttX system calls.

endif
19 changes: 19 additions & 0 deletions libc_bypass/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (C) 2024 Xiaomi Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

ifneq ($(CONFIG_WASM_LIBC_BYPASS),)
CONFIGURED_APPS += $(APPDIR)/frameworks/runtimes/wasm/libc_bypass
endif # CONFIG_WASM_LIBC_BYPASS
48 changes: 48 additions & 0 deletions libc_bypass/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Copyright (C) 2024 Xiaomi Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include $(APPDIR)/Make.defs

IWASM_ROOT := $(APPDIR)/interpreters/wamr

CSRCS += libc_bypass.c

#Filter compilation warnings for syscall library
CFLAGS += -Wno-unused-variable -Wno-int-conversion

WAMR_MODULE_NAME = libc_bypass


GLUECSRCS = syscall_glue.c libc_glue.c libm_glue.c
CSVSRCS = $(TOPDIR)/syscall/syscall.csv $(TOPDIR)/libs/libc/libc.csv $(TOPDIR)/libs/libm/libm.csv

$(GLUECSRCS): $(CSVSRCS) ../tools/mkwamrglue.py
$(Q) ../tools/mkwamrglue.py -i $(TOPDIR)/syscall/syscall.csv -o syscall_glue.c
$(Q) ../tools/mkwamrglue.py -i $(TOPDIR)/libs/libc/libc.csv -o libc_glue.c
$(Q) ../tools/mkwamrglue.py -i $(TOPDIR)/libs/libm/libm.csv -o libm_glue.c
gcc -shared -fPIC -o signature_libc.so signature_libc_glue.c -I$(IWASM_ROOT)
gcc -shared -fPIC -o signature_libm.so signature_libm_glue.c -I$(IWASM_ROOT)
gcc -shared -fPIC -o signature_syscall.so signature_syscall_glue.c -I$(IWASM_ROOT)

depend:: $(GLUECSRCS)

distclean::
$(call DELFILE, syscall_glue.c)
$(call DELFILE, libc_glue.c)
$(call DELFILE, libm_glue.c)

include $(APPDIR)/interpreters/wamr/Module.mk
include $(APPDIR)/Application.mk
Loading
Loading