[bug #62595] Add ability to read .env files into make and

2022-06-11 Thread Paul D. Smith
Follow-up Comment #7, bug #62595 (project make):

Thanks for the pointer to the spec, that's very helpful.  I agree that this
would be possible to implement.

I'm not interested in a flag like --envfile, that doesn't sound very useful. 
I would anticipate that most build systems would want to always include the
content of the file, and not require the user to add an option to the command
line.

I'm also not sure I agree that the right behavior is to always export every
variable in the file.  But these are details: the first thing is to decide
whether this needs to be added at all.

I was thinking about alternatives to adding new syntax, and the problem is
that there's not a very straightforward way in GNU make today to evaluate the
output of a program as a makefile.

We can run a program using $(shell ...), but the results are modified by
removing newlines and so this is not useful.

The only way to do it is to run $(shell ...) and have it write to a temporary
file, then include the temporary file.  Of course you can also use the re-exec
feature of make to write a rule to generate the include file then you have the
full power of a recipe.

Is that sufficient?  It would be something like:


include env.mk

env.mk: env.env
env2make < $< > $@


for some putative *env2make* conversion tool.

An alternative would be to invent some new type of function which would either
preserve newlines in the result, which could then be passed to the *eval*
function, or create an alternative to include which would run a program and
"include" the output, or something like that.


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #62615] Fix the leaks of file->cmds and file->cmds->commands

2022-06-11 Thread Dmitry Goncharov
Additional Item Attachment, bug #62615 (project make):

File name: sv62615_fix.diff   Size:1 KB


File name: sv62615_test.diff  Size:1 KB




___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #62615] Fix the leaks of file->cmds and file->cmds->commands

2022-06-11 Thread Dmitry Goncharov
URL:
  

 Summary: Fix the leaks of file->cmds and file->cmds->commands
 Project: make
   Submitter: dgoncharov
   Submitted: Sat 11 Jun 2022 01:52:52 PM UTC
Severity: 3 - Normal
  Item Group: Bug
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: SCM
Operating System: Any
   Fixed Release: None
   Triage Status: None


___

Follow-up Comments:


---
Date: Sat 11 Jun 2022 01:52:52 PM UTC By: Dmitry Goncharov 
Makefile like the following causes make to leak
file->cmds along with file->cmds->commands allocated for the 1st hello.o
rule.

+++
all: hello.o
hello.o: hello.h; $(info 1 $@ from $^)
hello.o: hello.c; $(info 2 $@ from $^)


To see the leak build with -fsanitize=leak


$ make
makefile2:5: warning: overriding recipe for target 'hello.o'
makefile2:4: warning: ignoring old recipe for target 'hello.o'
2 hello.o from hello.c hello.h
make: Nothing to be done for 'all'.

=
==13813==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7fb54a09bc9c in __interceptor_malloc
/var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x558a7a3aae35 in xmalloc ../src/misc.c:190
#2 0x558a7a3c1923 in record_files ../src/read.c:2011
#3 0x558a7a3b6f0d in eval ../src/read.c:1009
#4 0x558a7a3b2a3c in eval_makefile ../src/read.c:438
#5 0x558a7a3b0a38 in read_all_makefiles ../src/read.c:223
#6 0x558a7a397ff7 in main ../src/main.c:1971
#7 0x7fb54953bc4e in __libc_start_main (/lib64/libc.so.6+0x23c4e)

Indirect leak of 23 byte(s) in 1 object(s) allocated from:
#0 0x7fb54a09bc9c in __interceptor_malloc
/var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x7fb54a04660d in __interceptor_strndup
/var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:395
#2 0x558a7a3aaf88 in xstrndup ../src/misc.c:252
#3 0x558a7a3c1b07 in record_files ../src/read.c:2015
#4 0x558a7a3b6f0d in eval ../src/read.c:1009
#5 0x558a7a3b2a3c in eval_makefile ../src/read.c:438
#6 0x558a7a3b0a38 in read_all_makefiles ../src/read.c:223
#7 0x558a7a397ff7 in main ../src/main.c:1971
#8 0x7fb54953bc4e in __libc_start_main (/lib64/libc.so.6+0x23c4e)

SUMMARY: AddressSanitizer: 79 byte(s) leaked in 2 allocation(s).








___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/