1 |
On 10/6/2012 1:31 AM, Fabian Groffen wrote: |
2 |
> On 06-10-2012 00:47:57 -0700, Gregory M. Turner wrote: |
3 |
>> In dev-lang/python*, we use |
4 |
>> |
5 |
>> append-ldflags '-L.' |
6 |
>> |
7 |
>> to ensure linking is performed against the built libpython.so in-tree, |
8 |
>> rather than than in the one in $(libdir). But, this doesn't work if |
9 |
>> LDFLAGS contains "-L$(libdir)". |
10 |
>> |
11 |
>> We could try to fix this like: |
12 |
>> |
13 |
>> export LDFLAGS="-L. ${LDFLAGS}" |
14 |
>> |
15 |
>> or so. That would cover 99.9% of the cases out there. But very rarely, |
16 |
>> indiscriminately placing our '-L.' before every other clause in LDFLAGS |
17 |
>> might cause an unanticipated side-effect. |
18 |
> I think it would make more sense in this case to just add one more patch |
19 |
> to Python, such that the build-system just inserts it. I recall it's |
20 |
> necessary at least on FreeBSD, Darwin, Solaris, but I don't recall any |
21 |
> more why it works/worked on Linux fine. |
22 |
|
23 |
I was thinking along these lines as well. As it turned out, however, I |
24 |
was not able to find an automagical, PMS-compliant, non-crazy way to do |
25 |
it that resolved my test-case (more on that below), without effectively |
26 |
hooking econf(). |
27 |
|
28 |
Literally hooking a core API seems like a Pandora's box better left |
29 |
unopened, so this is what I came up with (note: the fpectl stuff was |
30 |
also in my overlay and the patches got entangled -- rather than editing |
31 |
the hunk by hand, I just left it. It's orthogonal to this issue, |
32 |
however, and for present purposes can be ignored): |
33 |
|
34 |
------>8-----> |
35 |
--- PORTAGE/dev-lang/python/python-2.7.3-r2.ebuild |
36 |
+++ OVERLAY/dev-lang/python/python-2.7.3-r2.ebuild |
37 |
@@ -218,13 +255,6 @@ |
38 |
# http://bugs.python.org/issue15506 |
39 |
export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG) |
40 |
|
41 |
- # Set LDFLAGS so we link modules with -lpython2.7 correctly. |
42 |
- # Needed on FreeBSD unless Python 2.7 is already installed. |
43 |
- # Please query BSD team before removing this! |
44 |
- # On AIX this is not needed, but would record '.' as runpath. |
45 |
- [[ ${CHOST} == *-aix* ]] || |
46 |
- append-ldflags "-L." |
47 |
- |
48 |
local dbmliborder |
49 |
if use gdbm; then |
50 |
dbmliborder+="${dbmliborder:+:}gdbm" |
51 |
@@ -248,11 +278,18 @@ |
52 |
&& myconf="${myconf} --enable-framework=${EPREFIX}/usr/lib" \ |
53 |
|| myconf="${myconf} --enable-shared" |
54 |
|
55 |
+ if [[ ${CHOST} == *-cygwin* ]] ; then |
56 |
+ fpeconfig="--without-fpectl" |
57 |
+ myconf="${myconf} ac_cv_func_bind_textdomain_codeset=yes" |
58 |
+ else |
59 |
+ fpeconfig="--with-fpectl" |
60 |
+ fi |
61 |
+ |
62 |
# note: for a framework build we need to use ucs2 because OSX |
63 |
# uses that internally too: |
64 |
# http://bugs.python.org/issue763708 |
65 |
- OPT="" econf \ |
66 |
- --with-fpectl \ |
67 |
+ OPT="" cpython_econf \ |
68 |
+ ${fpeconfig} \ |
69 |
$(use_enable ipv6) \ |
70 |
$(use_with threads) \ |
71 |
$( (use wide-unicode && use !aqua) && echo "--enable-unicode=ucs4" |
72 |
|| echo "--enable-unicode=ucs2") \ |
73 |
--- PORTAGE/eclass/python.eclass |
74 |
+++ OVERLAY/eclass/python.eclass |
75 |
@@ -401,6 +401,64 @@ |
76 |
fi |
77 |
} |
78 |
|
79 |
+# see http://thread.gmane.org/gmane.linux.gentoo.devel/80633/focus=80635 |
80 |
+_python_prepend_cwd_ldpath() { |
81 |
+ local new=() |
82 |
+ local f |
83 |
+ local done=no |
84 |
+ for f in ${LDFLAGS} ; do |
85 |
+ case "${f}" in |
86 |
+ -Tbss=*|-Tdata=*|-Ttext=*|-Ttext-segment=*) |
87 |
+ new+=( "${f}" ) |
88 |
+ ;; |
89 |
+ -L*|-T*|--library-path*|--script*) |
90 |
+ if [[ ${done} == yes ]] ; then |
91 |
+ new+=( "${f}" ) |
92 |
+ elif [[ "${f}" == "-L." ]] ; then |
93 |
+ # if it's somehow already there, don't duplicate it |
94 |
+ new+=( "-L." ) |
95 |
+ done=yes |
96 |
+ else |
97 |
+ new+=( "-L." "${f}" ) |
98 |
+ done=yes |
99 |
+ fi |
100 |
+ ;; |
101 |
+ *) |
102 |
+ new+=( "${f}" ) |
103 |
+ ;; |
104 |
+ esac |
105 |
+ done |
106 |
+ [[ ${done} == no ]] && new+=( "-L." ) |
107 |
+ export LDFLAGS="${new[*]}" |
108 |
+} |
109 |
+ |
110 |
+# @FUNCTION: cpython_econf |
111 |
+# @DESCRIPTION: |
112 |
+# econf() substitute for use in dev-lang/python ebuilds |
113 |
+# |
114 |
+# On some platforms, it is neccesary to prepend "-L." to ldpath before |
115 |
+# proceeding with python's configure process. Using cpython_econf() |
116 |
+# instead of econf() will ensure that this is taken care of correctly |
117 |
+# before python's configure step can proceed. This is not needed for |
118 |
+# any python ebuilds other than dev-lang/python; any other ebuild |
119 |
+# calling this function will receive an error. |
120 |
+cpython_econf() { |
121 |
+ if [[ "${CATEGORY}/${PN}" != "dev-lang/python" ]] ; then |
122 |
+ die "cpython_econf can only be used by dev-lang/python ebuilds" |
123 |
+ fi |
124 |
+ # econf will enforce ${EBUILD_PHASE} requirements, so we don't bother. |
125 |
+ |
126 |
+ # Set LDFLAGS so we link modules with -lpython2.7 correctly. |
127 |
+ # Needed on FreeBSD unless Python 2.7 is already installed. |
128 |
+ # Even if python is already installed, linking against the old |
129 |
+ # python will cause problems, i.e., when toggling USE="threads". |
130 |
+ # Also needed on cygwin. Please query BSD team before removing this! |
131 |
+ # On AIX this is not needed, and would record '.' as runpath. |
132 |
+ [[ ${CHOST} == *-aix* ]] || _python_prepend_cwd_ldpath |
133 |
+ |
134 |
+ econf "$@" |
135 |
+} |
136 |
+ |
137 |
# @FUNCTION: python_pkg_setup |
138 |
# @DESCRIPTION: |
139 |
# Perform sanity checks and initialize environment. |
140 |
<-----8<----- |
141 |
|
142 |
Some notes about the above: |
143 |
|
144 |
Of course we would presumably want to make a similar change in all of |
145 |
the dev-lang/python ebuilds to the one above. |
146 |
|
147 |
We could do this 100% automagically in python_pkg_setup, which was my |
148 |
initial plan. But my test-case involves LDPATH being "scrubbed" in |
149 |
every phase by profile.bashrc. After python_pkg_setup() changed LDPATH, |
150 |
it just broke again in subsequent phases (at least, I think that's what |
151 |
would have happened -- I never tested it). Yes, that's a GIGO problem; |
152 |
however, it's debatable whether Gentoo or profile.bashrc is the one |
153 |
putting the "G)arbage I)n". The most robust route is to insert our |
154 |
LDFLAG just before econf runs -- that's how the current implementation |
155 |
does it, after all, and we potentially create a regression if we move |
156 |
this logic to pkg_setup. |
157 |
|
158 |
Also, I decided to leave my internal API as "_python_foo," although |
159 |
today, I'd say "__python_foo" is more correct. python.eclass is chock |
160 |
full of "_python_foo" API's, so I decided it was probably cleaner to |
161 |
follow the existing patterns for now, rather than change one lone API |
162 |
while the rest remain unchanged. |
163 |
|
164 |
As for cpython_econf -- is it OK that it doesn't begin with "python"? |
165 |
Or should it perhaps be "python_cpython_econf?" |
166 |
|
167 |
Thanks for your input, |
168 |
|
169 |
-gmt |