Skip to content

Commit 55b9271

Browse files
andrewleechpi-anl
authored andcommitted
QNX / old compiler support
1 parent 6f4d424 commit 55b9271

File tree

16 files changed

+137
-17
lines changed

16 files changed

+137
-17
lines changed

extmod/axtls-include/axtls_os_port.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define AXTLS_OS_PORT_H
2828

2929
#include <errno.h>
30+
#include <sys/time.h>
3031
#include "py/stream.h"
3132
#include "lib/crypto-algorithms/sha256.h"
3233

extmod/vfs_posix.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ STATIC mp_obj_t vfs_posix_ilistdir_it_iternext(mp_obj_t self_in) {
200200
}
201201

202202
#ifdef _DIRENT_HAVE_D_TYPE
203+
203204
#ifdef DTTOIF
204205
t->items[1] = MP_OBJ_NEW_SMALL_INT(DTTOIF(dirent->d_type));
205206
#else

mpy-cross/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ INC += -I$(BUILD)
1717
INC += -I$(TOP)
1818

1919
# compiler settings
20-
CWARN = -Wall -Werror
20+
CWARN = -Wall # -Werror
2121
CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith
2222
CFLAGS += $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
2323
CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables

mpy-cross/mpconfigport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define MICROPY_PERSISTENT_CODE_SAVE (1)
3232

3333
#ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE
34-
#if defined(__i386__) || defined(__x86_64__) || defined(_WIN32) || defined(__unix__) || defined(__APPLE__)
34+
#if defined(__i386__) || defined(__x86_64__) || defined(_WIN32) || defined(__unix__) || defined(__APPLE__) || defined(__QNX__)
3535
#define MICROPY_PERSISTENT_CODE_SAVE_FILE (1)
3636
#else
3737
#define MICROPY_PERSISTENT_CODE_SAVE_FILE (0)
@@ -119,7 +119,7 @@ typedef long mp_off_t;
119119
#define MP_PLAT_PRINT_STRN(str, len) (void)0
120120

121121
// We need to provide a declaration/definition of alloca()
122-
#ifdef __FreeBSD__
122+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__QNX__)
123123
#include <stdlib.h>
124124
#elif defined(_WIN32)
125125
#include <malloc.h>

ports/unix/Makefile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ INC += -I$(TOP)
3737
INC += -I$(BUILD)
3838

3939
# compiler settings
40-
CWARN = -Wall -Werror
41-
CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith -Wdouble-promotion -Wfloat-conversion
40+
CWARN = -Wall #-Werror
41+
CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith
4242
CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA)
4343

4444
# Debugging/Optimization
@@ -100,7 +100,8 @@ else
100100
# Use gcc syntax for map file
101101
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
102102
endif
103-
LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
103+
LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm
104+
$(LDFLAGS_EXTRA)
104105

105106
# Flags to link with pthread library
106107
LIBPTHREAD = -lpthread
@@ -127,10 +128,18 @@ endif
127128
ifeq ($(MICROPY_PY_SOCKET),1)
128129
CFLAGS_MOD += -DMICROPY_PY_SOCKET=1
129130
SRC_MOD += modusocket.c
131+
ifeq ($(CROSS_COMPILE),ntoarmv7-)
132+
LDFLAGS_MOD += -Wl,-R/mnt/app/armle/lib -Wl,-R/lib -lsocket
133+
endif
130134
endif
131135
ifeq ($(MICROPY_PY_THREAD),1)
132136
CFLAGS_MOD += -DMICROPY_PY_THREAD=1 -DMICROPY_PY_THREAD_GIL=0
137+
138+
ifneq ($(CROSS_COMPILE),ntoarmv7-)
133139
LDFLAGS_MOD += $(LIBPTHREAD)
140+
else
141+
# on qnx pthread is included in libc
142+
endif
134143
endif
135144

136145
ifeq ($(MICROPY_PY_USSL),1)
@@ -212,14 +221,19 @@ LIBFFI_CFLAGS_MOD := -I$(shell ls -1d $(BUILD)/lib/libffi/out/lib/libffi-*/inclu
212221
LIBFFI_LDFLAGS_MOD = $(BUILD)/lib/libffi/out/lib/libffi.a
213222
endif
214223
else
215-
# Use system version of libffi.
216-
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
217-
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
224+
#LIBFFI_CFLAGS_MOD := $(shell pkg-config --static --cflags libffi)
225+
#LIBFFI_LDFLAGS_MOD := $(shell pkg-config --static --libs libffi)
226+
##PKG_CONFIG_PATH=/mnt/app/pkg/lib/pkgconfig pkg-config --static --cflags libffi
227+
LIBFFI_CFLAGS_MOD := -I/mnt/app/pkg/include
228+
LIBFFI_LDFLAGS_MOD := -L/mnt/app/pkg/lib -l:libffi.a
218229
endif
219230

231+
232+
ifneq ($(CROSS_COMPILE),ntoarmv7-)
220233
ifeq ($(UNAME_S),Linux)
221234
LIBFFI_LDFLAGS_MOD += -ldl
222235
endif
236+
endif
223237

224238
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
225239
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)

ports/unix/build.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export LC_ALL="en_US.UTF-8"
2+
export LC_CTYPE="en_US.UTF-8"
3+
export LANG="C.UTF-8"
4+
5+
gmake \
6+
CROSS_COMPILE=ntoarmv7- V=1 \
7+
CFLAGS_EXTRA=" \
8+
-static -static-libgcc \
9+
-DMP_ENDIANNESS_LITTLE=1 \
10+
-Wno-missing-field-initializers -Wno-strict-aliasing \
11+
-D_DIRENT_HAVE_D_TYPE=0 \
12+
" \
13+
MPY_LIB_DIR=../../../../packages/micropython-lib \
14+
MICROPY_STANDALONE=0 VARIANT=ext MICROPY_PY_BLUETOOTH=0 \
15+
FROZEN_MANIFEST=../../../../packages/manifest.py \
16+
PROG=micropython

ports/unix/modusocket.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <sys/stat.h>
3434
#include <sys/types.h>
3535
#include <sys/socket.h>
36+
#include <sys/time.h>
3637
#include <netinet/in.h>
3738
#include <arpa/inet.h>
3839
#include <netdb.h>

ports/unix/mpconfigport.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ static inline unsigned long mp_urandom_seed_init(void) {
307307
// the macros [...], _DIRENT_HAVE_D_TYPE are defined."
308308
// Other libc's don't define it, but proactively assume that dirent->d_type
309309
// is available on a modern *nix system.
310-
#ifndef _DIRENT_HAVE_D_TYPE
311-
#define _DIRENT_HAVE_D_TYPE (1)
312-
#endif
310+
// #ifndef _DIRENT_HAVE_D_TYPE
311+
// #define _DIRENT_HAVE_D_TYPE (1)
312+
// #endif
313313
// This macro is not provided by glibc but we need it so ports that don't have
314314
// dirent->d_ino can disable the use of this field.
315315
#ifndef _DIRENT_HAVE_D_INO
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Damien P. George
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#define MICROPY_READER_VFS (1)
28+
#define MICROPY_REPL_EMACS_WORDS_MOVE (1)
29+
#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (1)
30+
#define MICROPY_ENABLE_SCHEDULER (1)
31+
#define MICROPY_VFS (1)
32+
#define MICROPY_VFS_POSIX (1)
33+
34+
#define MICROPY_PY_BUILTINS_HELP (1)
35+
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
36+
#define MICROPY_PY_SYS_SETTRACE (1)
37+
#define MICROPY_PY_UOS_VFS (1)
38+
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
39+
40+
#ifndef MICROPY_PY_UASYNCIO
41+
#define MICROPY_PY_UASYNCIO (1)
42+
#endif
43+
44+
45+
#define MICROPY_OPT_MATH_FACTORIAL (1)
46+
#define MICROPY_FLOAT_HIGH_QUALITY_HASH (1)
47+
#define MICROPY_ENABLE_SCHEDULER (1)
48+
#define MICROPY_MODULE_GETATTR (1)
49+
#define MICROPY_PY_DELATTR_SETATTR (1)
50+
#define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (1)
51+
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
52+
#define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (1)
53+
#define MICROPY_PY_BUILTINS_NEXT2 (1)
54+
#define MICROPY_PY_BUILTINS_RANGE_BINOP (1)
55+
#define MICROPY_PY_SYS_GETSIZEOF (1)
56+
#define MICROPY_PY_MATH_FACTORIAL (1)
57+
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
58+
#define MICROPY_PY_IO_BUFFEREDWRITER (1)
59+
#define MICROPY_PY_IO_RESOURCE_STREAM (1)
60+
#define MICROPY_PY_URE_MATCH_GROUPS (1)
61+
#define MICROPY_PY_URE_MATCH_SPAN_START_END (1)
62+
#define MICROPY_PY_URE_SUB (1)
63+
#define MICROPY_PY_FRAMEBUF (1)
64+
#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (1)
65+
#define MICROPY_PY_UCRYPTOLIB (1)
66+
#define MICROPY_PY_UCRYPTOLIB_CTR (1)
67+
68+
69+
// Use vfs's functions for import stat and builtin open.
70+
#define mp_import_stat mp_vfs_import_stat
71+
#define mp_builtin_open mp_vfs_open
72+
#define mp_builtin_open_obj mp_vfs_open_obj
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PROG ?= micropython-dev
2+
3+
FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py
4+
5+
MICROPY_ROM_TEXT_COMPRESSION = 1
6+
MICROPY_VFS_FAT = 1
7+
MICROPY_VFS_LFS1 = 1
8+
MICROPY_VFS_LFS2 = 1
9+
10+
MICROPY_PY_BLUETOOTH ?= 1

0 commit comments

Comments
 (0)