1 |
On Thu, Mar 26, 2009 at 9:27 PM, Patrice Tisserand <ptisserand@××××××.com>wrote: |
2 |
|
3 |
> From: "Dennis.Yxun" <dennis.yxun@×××××.com> |
4 |
> Subject: [gentoo-embedded] Trying to Make Cross compile more firendly |
5 |
> Date: Thu, 26 Mar 2009 14:59:06 +0000 |
6 |
> |
7 |
> Hi Dennis, |
8 |
> |
9 |
> > HI Community: |
10 |
> > I'm trying to cross compile a stage1 base system for Openpandora. All |
11 |
> the |
12 |
> > steps can be followed in this wiki [1]. |
13 |
> Thanks for the link. |
14 |
> [cut] |
15 |
> > Actually the upstream provide two scripts [2] to setup the building |
16 |
> > environment. Which one is crossdev_set_environment.sh, it set SYSROOT |
17 |
> same |
18 |
> > with ROOT, another is set_environment.sh, which make ROOT different from |
19 |
> > SYSROOT. Since SYSROOT is the cross |
20 |
> > toolchain's environment, and ROOT is the target rootfs. I perfer to take |
21 |
> > set_set_environment.sh's way, It would seperate toolchains and target |
22 |
> > rootfs. So it will make the finanal rootfs more neat and clean, also |
23 |
> will |
24 |
> > avoid potential file confliction. That could be possible, for example |
25 |
> > the linux-headers, both cross toolchain and target rootfs will emerge. |
26 |
> Also |
27 |
> > maybe simply mark it as provided would solve this problem. |
28 |
> If you use a ROOT different of SYSROOT, you could have some issue with ld |
29 |
> linker |
30 |
> script. |
31 |
> If you look at content of libc.so linker script, you will something like: |
32 |
> GROUP (/lib/libc.so.6 ...) |
33 |
> According to http://sourceware.org/binutils/docs/ld/File-Commands.html , |
34 |
> it will |
35 |
> work when this file is in sysroot but not when out of the sysroot. |
36 |
> I have found there is a least the libc.so and libpthread.so linker script |
37 |
> which |
38 |
> have this issue. |
39 |
> But maybe the same issue could be present in other linker script. |
40 |
|
41 |
|
42 |
em.. this does require deep unstanding about LD linker working mechanism. |
43 |
is SYSROOT is related to cross-toolchain, so hardcoded? |
44 |
not sure whether we still can customize the library search paths. |
45 |
|
46 |
> |
47 |
> |
48 |
> > The upstream's default embedded's make.conf only look for header files |
49 |
> and |
50 |
> > library from ROOT's path. So if some lowlevel package |
51 |
> > looking for header file or library located at the toolchain's path, will |
52 |
> fail |
53 |
> > at complile stage. I come cross and idea, maybe it's possible to add |
54 |
> > both SYSROOT and ROOT's path into compiler's looking path.So I just |
55 |
> tweaked |
56 |
> > the CFLAGS and LDFLAGS[3]. I have no idea whill there be |
57 |
> > any problem with this. Still struggling and so far I got here. |
58 |
> I don't think it's necessary to add SYSROOT in headers and libraries search |
59 |
> path, since gcc already looking in his sysroot. |
60 |
> |
61 |
> |
62 |
make sense, agree |
63 |
|
64 |
> |
65 |
> > [3] LDFLAGS=" -L${ROOT}/lib -L/${ROOT}/usr/lib \ |
66 |
> > -L${SYSROOT}usr/lib -L${SYSROOT}lib \ |
67 |
> > " |
68 |
> > CFLAGS="-Os -pipe ${MARCH_TUNE} -fomit-frame-pointer \ |
69 |
> > -I${SYSROOT}/usr/include \ |
70 |
> > -I${SYSROOT}/include \ |
71 |
> > -I${ROOT}usr/include/ \ |
72 |
> > -I${ROOT}include/ \ |
73 |
> > " |
74 |
> For CFLAGS, I think it's better to replace -I${ROOT}/usr/include by |
75 |
> -isystem |
76 |
> ${ROOT}/usr/include |
77 |
|
78 |
|
79 |
> If in a sofware source code you have a fle name features.h, some #include |
80 |
> "features.h" and of course a -I. in his compilation CFLAGS. |
81 |
> If your CFLAGS are appending to the sofware CFLAGS, it's fine. |
82 |
> But if your CFLAGS are prepending to the software CFLAGS, it will use the |
83 |
> first |
84 |
> features.h found in -I directories. |
85 |
> With -isystem this issue only occurs if in the compilation CFLAGS there is |
86 |
> also |
87 |
> a -isystem (which is quite unusual I think). |
88 |
|
89 |
|
90 |
good suggestion |
91 |
|
92 |
> |
93 |
> |
94 |
> Regards, |
95 |
> Patrice. |
96 |
> |
97 |
> |