diff options
| author | Glenn Morris | 2013-12-13 13:25:30 -0500 |
|---|---|---|
| committer | Glenn Morris | 2013-12-13 13:25:30 -0500 |
| commit | 06a4f1102f40c2cb7ffa035b4f16b9039efaf95b (patch) | |
| tree | c365de8bc1db6dc73f2dc8b50a5b49488220bbd6 /src | |
| parent | 978a5fdaa35e8945920ab194213715e6f1f0bc20 (diff) | |
| download | emacs-06a4f1102f40c2cb7ffa035b4f16b9039efaf95b.tar.gz emacs-06a4f1102f40c2cb7ffa035b4f16b9039efaf95b.zip | |
Unconditionally reset load-path after dumping
* src/lread.c: (dump_path): Remove.
(load-path-default): Remove `changed' argument.
Do not set dump_path permanently. Simplify.
(init_lread): Simplify.
(syms_of_lread): Remove dump_path.
* lisp/loadup.el (load-path): Warn if site-load or site-init changes it.
No more need to reset it when bootstrapping.
* doc/lispref/internals.texi (Building Emacs):
* doc/lispref/loading.texi (Library Search): Mention that site-load,
site-init cannot change load-path.
* INSTALL: No longer mention load-path and site-init/site-load.
* etc/NEWS: Mention this.
Fixes: debbugs:16107
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/lread.c | 216 |
2 files changed, 94 insertions, 131 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4e8285e9530..0b0ed9452ee 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-12-13 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * lread.c: Unconditionally reset load-path after dumping. (Bug#16107) | ||
| 4 | (dump_path): Remove. | ||
| 5 | (load-path-default): Remove `changed' argument. | ||
| 6 | Do not set dump_path permanently. Simplify. | ||
| 7 | (init_lread): Simplify. | ||
| 8 | (syms_of_lread): Remove dump_path. | ||
| 9 | |||
| 1 | 2013-12-13 Dmitry Antipov <dmantipov@yandex.ru> | 10 | 2013-12-13 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 11 | ||
| 3 | * alloc.c, font.c, font.h, ftfont.c, ftxfont.c, macfont.m, | 12 | * alloc.c, font.c, font.h, ftfont.c, ftxfont.c, macfont.m, |
diff --git a/src/lread.c b/src/lread.c index a64f083a5ac..5d02b2bd20b 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -4128,10 +4128,6 @@ load_path_check (Lisp_Object lpath) | |||
| 4128 | } | 4128 | } |
| 4129 | } | 4129 | } |
| 4130 | 4130 | ||
| 4131 | /* Record the value of load-path used at the start of dumping | ||
| 4132 | so we can see if the site changed it later during dumping. */ | ||
| 4133 | static Lisp_Object dump_path; | ||
| 4134 | |||
| 4135 | /* Return the default load-path, to be used if EMACSLOADPATH is unset. | 4131 | /* Return the default load-path, to be used if EMACSLOADPATH is unset. |
| 4136 | This does not include the standard site-lisp directories | 4132 | This does not include the standard site-lisp directories |
| 4137 | under the installation prefix (i.e., PATH_SITELOADSEARCH), | 4133 | under the installation prefix (i.e., PATH_SITELOADSEARCH), |
| @@ -4145,18 +4141,16 @@ static Lisp_Object dump_path; | |||
| 4145 | If purify-flag (ie dumping) just use PATH_DUMPLOADSEARCH. | 4141 | If purify-flag (ie dumping) just use PATH_DUMPLOADSEARCH. |
| 4146 | Otherwise use PATH_LOADSEARCH. | 4142 | Otherwise use PATH_LOADSEARCH. |
| 4147 | 4143 | ||
| 4148 | If !initialized, then just set dump_path and return PATH_DUMPLOADSEARCH. | 4144 | If !initialized, then just return PATH_DUMPLOADSEARCH. |
| 4149 | If initialized, then if Vload_path != dump_path, return just Vload_path. | 4145 | If initialized: |
| 4150 | (Presumably the load-path has already been changed by something. | ||
| 4151 | This can only be from a site-load file during dumping.) | ||
| 4152 | If Vinstallation_directory is not nil (ie, running uninstalled): | 4146 | If Vinstallation_directory is not nil (ie, running uninstalled): |
| 4153 | If installation-dir/lisp exists and not already a member, | 4147 | If installation-dir/lisp exists and not already a member, |
| 4154 | we must be running uninstalled. Reset the load-path | 4148 | we must be running uninstalled. Reset the load-path |
| 4155 | to just installation-dir/lisp. (The default PATH_LOADSEARCH | 4149 | to just installation-dir/lisp. (The default PATH_LOADSEARCH |
| 4156 | refers to the eventual installation directories. Since we | 4150 | refers to the eventual installation directories. Since we |
| 4157 | are not yet installed, we should not use them, even if they exist.) | 4151 | are not yet installed, we should not use them, even if they exist.) |
| 4158 | If installation-dir/lisp does not exist, just add dump_path at the | 4152 | If installation-dir/lisp does not exist, just add |
| 4159 | end instead. | 4153 | PATH_DUMPLOADSEARCH at the end instead. |
| 4160 | Add installation-dir/site-lisp (if !no_site_lisp, and exists | 4154 | Add installation-dir/site-lisp (if !no_site_lisp, and exists |
| 4161 | and not already a member) at the front. | 4155 | and not already a member) at the front. |
| 4162 | If installation-dir != source-dir (ie running an uninstalled, | 4156 | If installation-dir != source-dir (ie running an uninstalled, |
| @@ -4165,7 +4159,7 @@ static Lisp_Object dump_path; | |||
| 4165 | check), then repeat the above steps for source-dir/lisp, site-lisp. */ | 4159 | check), then repeat the above steps for source-dir/lisp, site-lisp. */ |
| 4166 | 4160 | ||
| 4167 | static Lisp_Object | 4161 | static Lisp_Object |
| 4168 | load_path_default (bool changed) | 4162 | load_path_default () |
| 4169 | { | 4163 | { |
| 4170 | Lisp_Object lpath = Qnil; | 4164 | Lisp_Object lpath = Qnil; |
| 4171 | const char *normal; | 4165 | const char *normal; |
| @@ -4186,131 +4180,108 @@ load_path_default (bool changed) | |||
| 4186 | 4180 | ||
| 4187 | normal = NILP (Vpurify_flag) ? PATH_LOADSEARCH : PATH_DUMPLOADSEARCH; | 4181 | normal = NILP (Vpurify_flag) ? PATH_LOADSEARCH : PATH_DUMPLOADSEARCH; |
| 4188 | 4182 | ||
| 4189 | /* In a dumped Emacs, we normally reset the value of Vload_path using | ||
| 4190 | PATH_LOADSEARCH, since the value that was dumped uses lisp/ in | ||
| 4191 | the source directory, instead of the path of the installed elisp | ||
| 4192 | libraries. However, if it appears that Vload_path has already been | ||
| 4193 | changed from the default that was saved before dumping, don't | ||
| 4194 | change it further. Changes can only be due to site-lisp | ||
| 4195 | files that were processed during dumping. */ | ||
| 4196 | /* FIXME? AFAICS, it does not make sense to change load-path in a | ||
| 4197 | dumped site-lisp file, so maybe we should just drop this check. | ||
| 4198 | E.g., if you add an element to load-path, you are going to be | ||
| 4199 | adding it to PATH_DUMPLOADSEARCH, which refers to the source directory. | ||
| 4200 | This will make no sense (and may not still exist) in an installed Emacs. | ||
| 4201 | And the only change it is sensible to make to load-path is to add | ||
| 4202 | something to the front, which you should do with configure's | ||
| 4203 | --enable-locallisppath option if you really want to have it dumped. */ | ||
| 4204 | if (initialized) | 4183 | if (initialized) |
| 4205 | { | 4184 | { |
| 4206 | if (changed || NILP (Fequal (dump_path, Vload_path))) | ||
| 4207 | { | ||
| 4208 | /* Do not make any changes. */ | ||
| 4209 | return Vload_path; | ||
| 4210 | } | ||
| 4211 | else | ||
| 4212 | { | ||
| 4213 | #ifdef HAVE_NS | 4185 | #ifdef HAVE_NS |
| 4214 | const char *loadpath = ns_load_path (); | 4186 | const char *loadpath = ns_load_path (); |
| 4215 | lpath = decode_env_path (0, loadpath ? loadpath : normal, 0); | 4187 | lpath = decode_env_path (0, loadpath ? loadpath : normal, 0); |
| 4216 | #else | 4188 | #else |
| 4217 | lpath = decode_env_path (0, normal, 0); | 4189 | lpath = decode_env_path (0, normal, 0); |
| 4218 | #endif | 4190 | #endif |
| 4219 | if (!NILP (Vinstallation_directory)) | 4191 | if (!NILP (Vinstallation_directory)) |
| 4192 | { | ||
| 4193 | Lisp_Object tem, tem1; | ||
| 4194 | |||
| 4195 | /* Add to the path the lisp subdir of the installation | ||
| 4196 | dir, if it is accessible. Note: in out-of-tree builds, | ||
| 4197 | this directory is empty save for Makefile. */ | ||
| 4198 | tem = Fexpand_file_name (build_string ("lisp"), | ||
| 4199 | Vinstallation_directory); | ||
| 4200 | tem1 = Ffile_accessible_directory_p (tem); | ||
| 4201 | if (!NILP (tem1)) | ||
| 4202 | { | ||
| 4203 | if (NILP (Fmember (tem, lpath))) | ||
| 4204 | { | ||
| 4205 | /* We are running uninstalled. The default load-path | ||
| 4206 | points to the eventual installed lisp directories. | ||
| 4207 | We should not use those now, even if they exist, | ||
| 4208 | so start over from a clean slate. */ | ||
| 4209 | lpath = list1 (tem); | ||
| 4210 | } | ||
| 4211 | } | ||
| 4212 | else | ||
| 4213 | /* That dir doesn't exist, so add the build-time | ||
| 4214 | Lisp dirs instead. */ | ||
| 4220 | { | 4215 | { |
| 4221 | Lisp_Object tem, tem1; | 4216 | Lisp_Object dump_path = |
| 4217 | decode_env_path (0, PATH_DUMPLOADSEARCH, 0); | ||
| 4218 | lpath = nconc2 (lpath, dump_path); | ||
| 4219 | } | ||
| 4222 | 4220 | ||
| 4223 | /* Add to the path the lisp subdir of the installation | 4221 | /* Add site-lisp under the installation dir, if it exists. */ |
| 4224 | dir, if it is accessible. Note: in out-of-tree builds, | 4222 | if (!no_site_lisp) |
| 4225 | this directory is empty save for Makefile. */ | 4223 | { |
| 4226 | tem = Fexpand_file_name (build_string ("lisp"), | 4224 | tem = Fexpand_file_name (build_string ("site-lisp"), |
| 4227 | Vinstallation_directory); | 4225 | Vinstallation_directory); |
| 4228 | tem1 = Ffile_accessible_directory_p (tem); | 4226 | tem1 = Ffile_accessible_directory_p (tem); |
| 4229 | if (!NILP (tem1)) | 4227 | if (!NILP (tem1)) |
| 4230 | { | 4228 | { |
| 4231 | if (NILP (Fmember (tem, lpath))) | 4229 | if (NILP (Fmember (tem, lpath))) |
| 4232 | { | 4230 | lpath = Fcons (tem, lpath); |
| 4233 | /* We are running uninstalled. The default load-path | ||
| 4234 | points to the eventual installed lisp directories. | ||
| 4235 | We should not use those now, even if they exist, | ||
| 4236 | so start over from a clean slate. */ | ||
| 4237 | lpath = list1 (tem); | ||
| 4238 | } | ||
| 4239 | } | 4231 | } |
| 4240 | else | 4232 | } |
| 4241 | /* That dir doesn't exist, so add the build-time | ||
| 4242 | Lisp dirs instead. */ | ||
| 4243 | lpath = nconc2 (lpath, dump_path); | ||
| 4244 | 4233 | ||
| 4245 | /* Add site-lisp under the installation dir, if it exists. */ | 4234 | /* If Emacs was not built in the source directory, |
| 4246 | if (!no_site_lisp) | 4235 | and it is run from where it was built, add to load-path |
| 4247 | { | 4236 | the lisp and site-lisp dirs under that directory. */ |
| 4248 | tem = Fexpand_file_name (build_string ("site-lisp"), | ||
| 4249 | Vinstallation_directory); | ||
| 4250 | tem1 = Ffile_accessible_directory_p (tem); | ||
| 4251 | if (!NILP (tem1)) | ||
| 4252 | { | ||
| 4253 | if (NILP (Fmember (tem, lpath))) | ||
| 4254 | lpath = Fcons (tem, lpath); | ||
| 4255 | } | ||
| 4256 | } | ||
| 4257 | 4237 | ||
| 4258 | /* If Emacs was not built in the source directory, | 4238 | if (NILP (Fequal (Vinstallation_directory, Vsource_directory))) |
| 4259 | and it is run from where it was built, add to load-path | 4239 | { |
| 4260 | the lisp and site-lisp dirs under that directory. */ | 4240 | Lisp_Object tem2; |
| 4241 | |||
| 4242 | tem = Fexpand_file_name (build_string ("src/Makefile"), | ||
| 4243 | Vinstallation_directory); | ||
| 4244 | tem1 = Ffile_exists_p (tem); | ||
| 4261 | 4245 | ||
| 4262 | if (NILP (Fequal (Vinstallation_directory, Vsource_directory))) | 4246 | /* Don't be fooled if they moved the entire source tree |
| 4247 | AFTER dumping Emacs. If the build directory is indeed | ||
| 4248 | different from the source dir, src/Makefile.in and | ||
| 4249 | src/Makefile will not be found together. */ | ||
| 4250 | tem = Fexpand_file_name (build_string ("src/Makefile.in"), | ||
| 4251 | Vinstallation_directory); | ||
| 4252 | tem2 = Ffile_exists_p (tem); | ||
| 4253 | if (!NILP (tem1) && NILP (tem2)) | ||
| 4263 | { | 4254 | { |
| 4264 | Lisp_Object tem2; | 4255 | tem = Fexpand_file_name (build_string ("lisp"), |
| 4265 | 4256 | Vsource_directory); | |
| 4266 | tem = Fexpand_file_name (build_string ("src/Makefile"), | ||
| 4267 | Vinstallation_directory); | ||
| 4268 | tem1 = Ffile_exists_p (tem); | ||
| 4269 | |||
| 4270 | /* Don't be fooled if they moved the entire source tree | ||
| 4271 | AFTER dumping Emacs. If the build directory is indeed | ||
| 4272 | different from the source dir, src/Makefile.in and | ||
| 4273 | src/Makefile will not be found together. */ | ||
| 4274 | tem = Fexpand_file_name (build_string ("src/Makefile.in"), | ||
| 4275 | Vinstallation_directory); | ||
| 4276 | tem2 = Ffile_exists_p (tem); | ||
| 4277 | if (!NILP (tem1) && NILP (tem2)) | ||
| 4278 | { | ||
| 4279 | tem = Fexpand_file_name (build_string ("lisp"), | ||
| 4280 | Vsource_directory); | ||
| 4281 | 4257 | ||
| 4282 | if (NILP (Fmember (tem, lpath))) | 4258 | if (NILP (Fmember (tem, lpath))) |
| 4283 | lpath = Fcons (tem, lpath); | 4259 | lpath = Fcons (tem, lpath); |
| 4284 | 4260 | ||
| 4285 | if (!no_site_lisp) | 4261 | if (!no_site_lisp) |
| 4262 | { | ||
| 4263 | tem = Fexpand_file_name (build_string ("site-lisp"), | ||
| 4264 | Vsource_directory); | ||
| 4265 | tem1 = Ffile_accessible_directory_p (tem); | ||
| 4266 | if (!NILP (tem1)) | ||
| 4286 | { | 4267 | { |
| 4287 | tem = Fexpand_file_name (build_string ("site-lisp"), | 4268 | if (NILP (Fmember (tem, lpath))) |
| 4288 | Vsource_directory); | 4269 | lpath = Fcons (tem, lpath); |
| 4289 | tem1 = Ffile_accessible_directory_p (tem); | ||
| 4290 | if (!NILP (tem1)) | ||
| 4291 | { | ||
| 4292 | if (NILP (Fmember (tem, lpath))) | ||
| 4293 | lpath = Fcons (tem, lpath); | ||
| 4294 | } | ||
| 4295 | } | 4270 | } |
| 4296 | } | 4271 | } |
| 4297 | } /* Vinstallation_directory != Vsource_directory */ | 4272 | } |
| 4298 | 4273 | } /* Vinstallation_directory != Vsource_directory */ | |
| 4299 | } /* if Vinstallation_directory */ | ||
| 4300 | 4274 | ||
| 4301 | } /* if dump_path == Vload_path */ | 4275 | } /* if Vinstallation_directory */ |
| 4302 | } | 4276 | } |
| 4303 | else /* !initialized */ | 4277 | else /* !initialized */ |
| 4304 | { | 4278 | { |
| 4305 | /* NORMAL refers to PATH_DUMPLOADSEARCH, ie the lisp dir in the | 4279 | /* NORMAL refers to PATH_DUMPLOADSEARCH, ie the lisp dir in the |
| 4306 | source directory. We used to add ../lisp (ie the lisp dir in | 4280 | source directory. We used to add ../lisp (ie the lisp dir in |
| 4307 | the build directory) at the front here, but that caused trouble | 4281 | the build directory) at the front here, but that should not |
| 4308 | because it was copied from dump_path into Vload_path, above, | 4282 | be necessary, since in out of tree builds lisp/ is empty, save |
| 4309 | when Vinstallation_directory was non-nil. It should not be | ||
| 4310 | necessary, since in out of tree builds lisp/ is empty, save | ||
| 4311 | for Makefile. */ | 4283 | for Makefile. */ |
| 4312 | lpath = decode_env_path (0, normal, 0); | 4284 | lpath = decode_env_path (0, normal, 0); |
| 4313 | dump_path = lpath; | ||
| 4314 | } | 4285 | } |
| 4315 | #endif /* !CANNOT_DUMP */ | 4286 | #endif /* !CANNOT_DUMP */ |
| 4316 | 4287 | ||
| @@ -4322,27 +4293,20 @@ init_lread (void) | |||
| 4322 | { | 4293 | { |
| 4323 | /* First, set Vload_path. */ | 4294 | /* First, set Vload_path. */ |
| 4324 | 4295 | ||
| 4325 | /* NB: Do not change Vload_path before calling load_path_default, | ||
| 4326 | since it may check it against dump_path. | ||
| 4327 | (This behavior could be changed.) */ | ||
| 4328 | |||
| 4329 | /* We explicitly ignore EMACSLOADPATH when dumping. */ | 4296 | /* We explicitly ignore EMACSLOADPATH when dumping. */ |
| 4330 | if (NILP (Vpurify_flag) && egetenv ("EMACSLOADPATH")) | 4297 | if (NILP (Vpurify_flag) && egetenv ("EMACSLOADPATH")) |
| 4331 | { | 4298 | { |
| 4332 | Lisp_Object elpath = decode_env_path ("EMACSLOADPATH", 0, 1); | 4299 | Vload_path = decode_env_path ("EMACSLOADPATH", 0, 1); |
| 4333 | 4300 | ||
| 4334 | /* Check (non-nil) user-supplied elements. */ | 4301 | /* Check (non-nil) user-supplied elements. */ |
| 4335 | load_path_check (elpath); | 4302 | load_path_check (Vload_path); |
| 4336 | 4303 | ||
| 4337 | /* If no nils in the environment variable, use as-is. | 4304 | /* If no nils in the environment variable, use as-is. |
| 4338 | Otherwise, replace any nils with the default. */ | 4305 | Otherwise, replace any nils with the default. */ |
| 4339 | if (NILP (Fmemq (Qnil, elpath))) | 4306 | if (! NILP (Fmemq (Qnil, Vload_path))) |
| 4340 | { | ||
| 4341 | Vload_path = elpath; | ||
| 4342 | } | ||
| 4343 | else | ||
| 4344 | { | 4307 | { |
| 4345 | Lisp_Object elem, default_lpath = load_path_default (0); | 4308 | Lisp_Object elem, elpath = Vload_path; |
| 4309 | Lisp_Object default_lpath = load_path_default (); | ||
| 4346 | 4310 | ||
| 4347 | /* Check defaults, before adding site-lisp. */ | 4311 | /* Check defaults, before adding site-lisp. */ |
| 4348 | load_path_check (default_lpath); | 4312 | load_path_check (default_lpath); |
| @@ -4372,13 +4336,7 @@ init_lread (void) | |||
| 4372 | } | 4336 | } |
| 4373 | else /* Vpurify_flag || !EMACSLOADPATH */ | 4337 | else /* Vpurify_flag || !EMACSLOADPATH */ |
| 4374 | { | 4338 | { |
| 4375 | #ifdef CANNOT_DUMP | 4339 | Vload_path = load_path_default (); |
| 4376 | bool changed = 0; | ||
| 4377 | #else | ||
| 4378 | bool changed = initialized && NILP (Fequal (dump_path, Vload_path)); | ||
| 4379 | #endif | ||
| 4380 | |||
| 4381 | Vload_path = load_path_default (changed); | ||
| 4382 | 4340 | ||
| 4383 | /* Check before adding site-lisp directories. | 4341 | /* Check before adding site-lisp directories. |
| 4384 | The install should have created them, but they are not | 4342 | The install should have created them, but they are not |
| @@ -4386,10 +4344,8 @@ init_lread (void) | |||
| 4386 | Or we might be running before installation. */ | 4344 | Or we might be running before installation. */ |
| 4387 | load_path_check (Vload_path); | 4345 | load_path_check (Vload_path); |
| 4388 | 4346 | ||
| 4389 | /* Add the site-lisp directories at the front, unless the | 4347 | /* Add the site-lisp directories at the front. */ |
| 4390 | load-path has already been changed. | 4348 | if (initialized && !no_site_lisp) |
| 4391 | FIXME? Should we ignore changed here? */ | ||
| 4392 | if (initialized && !no_site_lisp && !changed) | ||
| 4393 | { | 4349 | { |
| 4394 | Lisp_Object sitelisp; | 4350 | Lisp_Object sitelisp; |
| 4395 | sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0); | 4351 | sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0); |
| @@ -4694,8 +4650,6 @@ variables, this must be set in the first line of a file. */); | |||
| 4694 | DEFSYM (Qdir_ok, "dir-ok"); | 4650 | DEFSYM (Qdir_ok, "dir-ok"); |
| 4695 | DEFSYM (Qdo_after_load_evaluation, "do-after-load-evaluation"); | 4651 | DEFSYM (Qdo_after_load_evaluation, "do-after-load-evaluation"); |
| 4696 | 4652 | ||
| 4697 | staticpro (&dump_path); | ||
| 4698 | |||
| 4699 | staticpro (&read_objects); | 4653 | staticpro (&read_objects); |
| 4700 | read_objects = Qnil; | 4654 | read_objects = Qnil; |
| 4701 | staticpro (&seen_list); | 4655 | staticpro (&seen_list); |