Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0119-stdlib-Preserve-cwd-when-compiling-using-c...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0119-stdlib-Preserve-cwd-when-compiling-using-c-c-1.patch of Package erlang
From e9e98dfd56062da4b966a478e8c05bff6f6af416 Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Mon, 9 Oct 2023 15:54:10 +0200 Subject: [PATCH] stdlib: Preserve cwd when compiling using c:c/1 --- lib/stdlib/src/c.erl | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/stdlib/src/c.erl b/lib/stdlib/src/c.erl index f95852b890..d05b75425d 100644 --- a/lib/stdlib/src/c.erl +++ b/lib/stdlib/src/c.erl @@ -333,22 +333,43 @@ find_beam_1(Module) -> %% -will try to find and examine the beam file if not in memory %% -will not cause a module to become loaded by accident compile_info(Module, Beam) when is_atom(Module) -> + case erlang:module_loaded(Module) of true -> %% getting the compile info for a loaded module should normally %% work, but return an empty info list if it fails - try erlang:get_module_info(Module, compile) - catch _:_ -> [] + try compile_info_add_cwd(Beam, erlang:get_module_info(Module, compile)) + catch _:_ -> compile_info_add_cwd(Beam, []) end; false -> case beam_lib:chunks(Beam, [compile_info]) of {ok, {_Module, [{compile_info, Info}]}} -> - Info; + compile_info_add_cwd(Beam, Info); Error -> Error end end. +compile_info_add_cwd(Beam, Info) -> + CwdOpts = + case beam_lib:chunks(Beam, [debug_info]) of + {ok, {_,[{debug_info,{debug_info_v1,erl_abstract_code,{_AST,Meta}}}]}} -> + case proplists:get_value(cwd, Meta) of + undefined -> + []; + Cwd -> + [{i, Cwd}] + end; + _ -> + [] + end, + case lists:keytake(options, 1, Info) of + false -> + [{options, CwdOpts}]; + {value, {options, Options}, InfoNoOpts} -> + [{options, Options ++ CwdOpts} | InfoNoOpts] + end. + %% compile module, backing up any existing target file and restoring the %% old version if compilation fails (this should only be used when we have %% an old beam file that we want to preserve) -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor