bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multi-threaded compiling


From: Mischa Baars
Subject: Re: multi-threaded compiling
Date: Fri, 15 Mar 2024 09:17:00 +0100

No? No further suggestions?

Then I'd like to thank you all for your help and your input.

I'll be off-list now.

Kind regards,
Mischa Baars.

On Thu, Mar 14, 2024 at 9:17 AM Mischa Baars <mjbaars1977.backup@gmail.com>
wrote:

> Ok. Then this is what I was able to make of it. To be honest, I prefer the
> Makefile syntax over the script syntax, because of its direct substitutions.
>
> Other improvements that anyone likes to suggest? Is this the best bash can
> do?
>
>
> On Thu, Mar 14, 2024 at 3:47 AM Martin D Kealey <martin@kurahaupo.gen.nz>
> wrote:
>
>> On Wed, 13 Mar 2024, Mischa Baars wrote:
>>
>> > Date: Wed, 13 Mar 2024 22:52:16
>> > From: Mischa Baars <mjbaars1977.backup@gmail.com>
>> > To: alex xmb sw ratchev <fxmbsw7@gmail.com>
>> > Cc: psmith@gnu.org, bug-bash <bug-bash@gnu.org>, help-make@gnu.org
>> > Subject: Re: multi-threaded compiling
>> >
>> > I found another mistake of mine:
>> >
>> > #ifndef __STRINGIZED__
>> >
>> > should be
>> >
>> > #if __STRINGIZED__ == 0
>> >
>> > or it will always go for the second statement in the conditional.
>> >
>> > Can someone please correct my script??? Things are starting to itch.
>>
>> The fundamental limitation is that Bash only provides lists of scalars
>> masquerading as arrays, and lists of scalar-scalar pairs masquerading as
>> maps (aka hashes, dicts, or "associative arrays").
>>
>> It does not support any more complex data structures, and in particular,
>> does not have arrays-of-arrays or lists-of-lists.
>>
>> So I would change
>>
>>   CFLAGS[0]="-D__STRINGIZED__=0 -D__STRING__=\"${STR[0]}\""
>>   CFLAGS[1]="-D__STRINGIZED__=0 -D__STRING__=\"${STR[1]}\""
>>   CFLAGS[2]="-D__STRINGIZED__=1 -D__STRING__=\"${STR[0]}\""
>>   CFLAGS[3]="-D__STRINGIZED__=1 -D__STRING__=\"${STR[1]}\""
>>
>> to
>>
>>   CFLAGS0=( -D__STRINGIZED__=0 -D__STRING__="${STR[0]}" )
>>   CFLAGS1=( -D__STRINGIZED__=0 -D__STRING__="${STR[1]}" )
>>   CFLAGS2=( -D__STRINGIZED__=1 -D__STRING__="${STR[0]}" )
>>   CFLAGS3=( -D__STRINGIZED__=1 -D__STRING__="${STR[1]}" )
>>
>> and then change
>>
>>   gcc -o main main.c ${CFLAGS[0]} ; ./main
>>   gcc -o main main.c ${CFLAGS[1]} ; ./main
>>   gcc -o main main.c ${CFLAGS[2]} ; ./main
>>   gcc -o main main.c ${CFLAGS[3]} ; ./main
>>
>> to
>>
>>   gcc -o main main.c "${CFLAGS0[@]}" && ./main
>>   gcc -o main main.c "${CFLAGS1[@]}" && ./main
>>   gcc -o main main.c "${CFLAGS2[@]}" && ./main
>>   gcc -o main main.c "${CFLAGS3[@]}" && ./main
>>
>> If you absolutely must have some kind one indexed array for all the
>> permutations of cflags, then you could use a synthetic multidimensional
>> array, like this:
>>
>>   CFLAGS=( -D__STRINGIZED__=0 -D__STRING__="${STR[0]}"
>>            -D__STRINGIZED__=0 -D__STRING__="${STR[1]}"
>>            -D__STRINGIZED__=1 -D__STRING__="${STR[0]}"
>>            -D__STRINGIZED__=1 -D__STRING__="${STR[1]}" )
>>
>>   gcc -o main main.c "${CFLAGS[@]:0*2:2}" && ./main
>>   gcc -o main main.c "${CFLAGS[@]:1*2:2}" && ./main
>>   gcc -o main main.c "${CFLAGS[@]:2*2:2}" && ./main
>>   gcc -o main main.c "${CFLAGS[@]:3*2:2}" && ./main
>>
>> However, given the pattern, I'd have gone with:
>>
>>   for i in 0 1 2 3 ; do
>>     gcc -o main main.c -D__STRINGIZED__=$((i/2))
>> -D__STRING__="${STR[i%2]}" &&
>>     ./main
>>   done
>>
>> -Martin
>>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]