Skip to content

Commit 5048d6b

Browse files
no1wudixiaoxiang781216
authored andcommitted
tools: Add essential math.h for wasm build
If the experimental feature Wasm build enabled with multi thread compiling, the COPYFILE (cp) maybe raise the error below: ``` cp: cannot create regular file 'math.h': file exists ``` This error cause by that the wasi-sdk don't provide the math.h for non-wasi envrioment, for this case, provide a math.h for it instead of copy file each time is better. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
1 parent 2d5afd0 commit 5048d6b

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

include/wasm/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

include/wasm/math.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/****************************************************************************
2+
* apps/include/wasm/math.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
#ifndef __INCLUDE_WASM_MATH_H
22+
#define __INCLUDE_WASM_MATH_H
23+
24+
/****************************************************************************
25+
* Included Files
26+
****************************************************************************/
27+
28+
/* Forwards math.h to nuttx/include/nuttx/lib/math.h */
29+
30+
#include <nuttx/lib/math.h>
31+
32+
#endif /* __INCLUDE_WASM_MATH_H */

tools/Wasm.mk

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,12 @@ WAMR_MODE ?= INT
7575
WSRCS := $(MAINSRC) $(CSRCS)
7676
WOBJS := $(WSRCS:=$(SUFFIX).wo)
7777

78-
# Copy math.h from $(TOPDIR)/include/nuttx/lib/math.h to $(APPDIR)/include/wasm/math.h
79-
# Using declaration of math.h is OK for Wasm build
80-
81-
$(APPDIR)$(DELIM)include$(DELIM)wasm$(DELIM)math.h:
82-
ifeq ($(CONFIG_LIBM),)
83-
$(call COPYFILE,$(TOPDIR)$(DELIM)include$(DELIM)nuttx$(DELIM)lib$(DELIM)math.h,$@)
84-
endif
85-
8678
all:: $(WBIN)
8779

8880
$(BINDIR)/wasm:
8981
$(Q) mkdir -p $(BINDIR)/wasm
9082

91-
depend:: $(APPDIR)$(DELIM)include$(DELIM)wasm$(DELIM)math.h $(BINDIR)/wasm
83+
depend:: $(BINDIR)/wasm
9284

9385
$(WOBJS): %.c$(SUFFIX).wo : %.c
9486
$(Q) $(WCC) $(WCFLAGS) -c $^ -o $@
@@ -108,7 +100,6 @@ $(WBIN): $(WOBJS)
108100
clean::
109101
$(call DELFILE, $(WOBJS))
110102
$(call DELFILE, $(WBIN))
111-
$(call DELFILE, $(APPDIR)$(DELIM)include$(DELIM)wasm$(DELIM)math.h)
112103

113104
endif # WASM_BUILD
114105

0 commit comments

Comments
 (0)