]>
Commit | Line | Data |
---|---|---|
b5b0b447 ER |
1 | 2011-04-04 Jakub Jelinek <jakub@redhat.com> |
2 | ||
3 | * toplev.c (toplev_main_argv): New variable. | |
4 | (toplev_main): Initialize it. | |
5 | * graphite.c (init_cloog_pointers): Load libcloog-isl.so.4 from gcc's private | |
6 | directory. | |
7 | ||
8 | --- gcc/toplev.c.jj 2008-12-09 23:59:10.000000000 +0100 | |
9 | +++ gcc/toplev.c 2009-01-27 14:33:52.000000000 +0100 | |
10 | @@ -107,6 +107,8 @@ static bool no_backend; | |
11 | /* Length of line when printing switch values. */ | |
12 | #define MAX_LINE 75 | |
13 | ||
14 | +const char **toplev_main_argv; | |
15 | + | |
16 | /* Decoded options, and number of such options. */ | |
17 | struct cl_decoded_option *save_decoded_options; | |
18 | unsigned int save_decoded_options_count; | |
19 | @@ -1909,6 +1911,8 @@ toplev_main (int argc, char **argv) | |
20 | ||
21 | expandargv (&argc, &argv); | |
22 | ||
23 | + toplev_main_argv = CONST_CAST2 (const char **, char **, argv); | |
24 | + | |
25 | /* Initialization of GCC's environment, and diagnostics. */ | |
26 | general_init (argv[0]); | |
27 | ||
28 | --- gcc/graphite.c.jj 2010-12-01 10:24:32.000000000 -0500 | |
29 | +++ gcc/graphite.c 2010-12-01 11:46:07.832118193 -0500 | |
30 | @@ -72,11 +72,39 @@ __typeof (cloog_pointers__) cloog_pointe | |
31 | static bool | |
32 | init_cloog_pointers (void) | |
33 | { | |
34 | - void *h; | |
35 | - | |
36 | - if (cloog_pointers__.inited) | |
37 | - return cloog_pointers__.h != NULL; | |
38 | - h = dlopen ("libcloog-isl.so.4", RTLD_LAZY); | |
39 | + void *h = NULL; | |
40 | + extern const char **toplev_main_argv; | |
41 | + char *buf, *p; | |
42 | + size_t len; | |
43 | + | |
44 | + if (cloog_pointers__.inited) | |
45 | + return cloog_pointers__.h != NULL; | |
46 | + len = progname - toplev_main_argv[0]; | |
47 | + buf = XALLOCAVAR (char, len + sizeof "libcloog-isl.so.4"); | |
48 | + memcpy (buf, toplev_main_argv[0], len); | |
49 | + strcpy (buf + len, "libcloog-isl.so.4"); | |
50 | + len += sizeof "libcloog-isl.so.4"; | |
51 | + p = strstr (buf, "/libexec/"); | |
52 | + if (p != NULL) | |
53 | + { | |
54 | + while (1) | |
55 | + { | |
56 | + char *q = strstr (p + 8, "/libexec/"); | |
57 | + if (q == NULL) | |
58 | + break; | |
59 | + p = q; | |
60 | + } | |
61 | + memmove (p + 4, p + 8, len - (p + 8 - buf)); | |
62 | + h = dlopen (buf, RTLD_LAZY); | |
63 | + if (h == NULL) | |
64 | + { | |
65 | + len = progname - toplev_main_argv[0]; | |
66 | + memcpy (buf, toplev_main_argv[0], len); | |
67 | + strcpy (buf + len, "libcloog-isl.so.4"); | |
68 | + } | |
69 | + } | |
70 | + if (h == NULL) | |
71 | + h = dlopen (buf, RTLD_LAZY); | |
72 | cloog_pointers__.h = h; | |
73 | if (h == NULL) | |
74 | return false; |