Skip to content

Commit 29a2a1e

Browse files
committed
auto merge of #6234 : yichoi/rust/glob-dummy-pull, r=thestinger
transitional patch to resolve compile/link failure on android after #6161 landed, I've encountered below errors since android does not support glob in libc. /opt/ndk_standalone/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/yichoi/rust_work/build/x86_64-unknown-linux-gnu/stage1/lib/rustc/arm-linux-androideabi/lib/libcore-c3ca5d77d81b46c1-0.7-pre.so: error: undefined reference to 'glob' /opt/ndk_standalone/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/yichoi/rust_work/build/x86_64-unknown-linux-gnu/stage1/lib/rustc/arm-linux-androideabi/lib/libcore-c3ca5d77d81b46c1-0.7-pre.so: error: undefined reference to 'globfre Since android does not have `glob.h`, `glob_t` definition comes from https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/vSH6MWPD0Vk #6100 should be resolved.
2 parents d74ac9e + 987ad9c commit 29a2a1e

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/rt/rust_android_dummy.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#ifdef __ANDROID__
6+
57
#include "rust_android_dummy.h"
68
#include <math.h>
79
#include <errno.h>
810

9-
#ifdef __ANDROID__
10-
1111
int backtrace(void **array, int size) { return 0; }
1212

1313
char **backtrace_symbols(void *const *array, int size) { return 0; }
@@ -59,7 +59,21 @@ extern "C" void srand()
5959
extern "C" void atof()
6060
{
6161
}
62+
6263
extern "C" void tgammaf()
6364
{
6465
}
66+
67+
extern "C" int glob(const char *pattern,
68+
int flags,
69+
int (*errfunc) (const char *epath, int eerrno),
70+
glob_t *pglob)
71+
{
72+
return 0;
73+
}
74+
75+
extern "C" void globfree(glob_t *pglob)
76+
{
77+
}
78+
6579
#endif

src/rt/rust_android_dummy.h

+23
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,27 @@ char **backtrace_symbols (void *__const *__array, int __size);
1111

1212
void backtrace_symbols_fd (void *__const *__array, int __size, int __fd);
1313

14+
#include <sys/types.h>
15+
16+
struct stat;
17+
typedef struct {
18+
size_t gl_pathc; /* Count of total paths so far. */
19+
size_t gl_matchc; /* Count of paths matching pattern. */
20+
size_t gl_offs; /* Reserved at beginning of gl_pathv. */
21+
int gl_flags; /* Copy of flags parameter to glob. */
22+
char **gl_pathv; /* List of paths matching pattern. */
23+
/* Copy of errfunc parameter to glob. */
24+
int (*gl_errfunc)(const char *, int);
25+
26+
/*
27+
* Alternate filesystem access methods for glob; replacement
28+
* versions of closedir(3), readdir(3), opendir(3), stat(2)
29+
* and lstat(2).
30+
*/
31+
void (*gl_closedir)(void *);
32+
struct dirent *(*gl_readdir)(void *);
33+
void *(*gl_opendir)(const char *);
34+
int (*gl_lstat)(const char *, struct stat *);
35+
} glob_t;
36+
1437
#endif

0 commit comments

Comments
 (0)