Re: Need help: alternative module inclusion - duplicate symbols

2024-02-26 Thread Vladimir 'phcoder' Serbinenko
You can add a dispatcher which switches between 2 modules. E.g.
real_do_stuff (...);
fake_do_stuff(...);

static int (*do_stuff)( ...);
And switch pointer between 2 implementations. See terminal output and
grub_xputs for examples

On Mon, Feb 26, 2024 at 1:51 PM Michael Lawnick via Grub-devel
 wrote:
>
> Hi group,
>
> hope you can help me:
> I have modules pci_fpga.c and pci_fpga_emul.c with same functions in
> them but different implementation, one for the real device, the other
> one is just emulating.
>
> What I now want is being able to include one of both versions through
> build command. I started with this:
>
> Makefile.core.def:
> ...
> module = {
>   name = pci_fpga;
>   common = startlib/board/pci_fpga.c;
>   enable = efi;
> };
>
> module = {
>   name = pci_fpga_emul;
>   common = startlib/board/pci_fpga_emul.c;
>   enable = efi;
> };
> ...
>
> but then I get duplicate symbols error even without giving pci_fpga or
> pci_fpga_emul on the build.
>
> For using different packages than 'common' like this
> module = {
>   name = pci_fpga;
>   pci_fpga = startlib/board/pci_fpga.c;
>   enable = efi;
> };
> I could not find means to get pci_fpga included.
>
> Same problem if trying to approach it via different enable flag: How to do?
>
> Can anybody help? In docs I couldn't find usable hints.
>
> --
> KR
> Michael
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



-- 
Regards
Vladimir 'phcoder' Serbinenko

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: Need help: alternative module inclusion - duplicate symbols

2024-02-26 Thread Michael Lawnick via Grub-devel
Using function pointers solves the duplicate symbol problem.
But still there is a way needed to get the information passed into build.
FPGA is so essential in my use case that the configuration must be
compiled-in. But as the sources are under git a #define is not a good
option.

Am 26.02.2024 um 14:38 schrieb Vladimir 'phcoder' Serbinenko:
> You can add a dispatcher which switches between 2 modules. E.g.
> real_do_stuff (...);
> fake_do_stuff(...);
>
> static int (*do_stuff)( ...);
> And switch pointer between 2 implementations. See terminal output and
> grub_xputs for examples
>
> On Mon, Feb 26, 2024 at 1:51 PM Michael Lawnick via Grub-devel
>  wrote:
>>
>> Hi group,
>>
>> hope you can help me:
>> I have modules pci_fpga.c and pci_fpga_emul.c with same functions in
>> them but different implementation, one for the real device, the other
>> one is just emulating.
>>
>> What I now want is being able to include one of both versions through
>> build command. I started with this:
>>
>> Makefile.core.def:
>> ...
>> module = {
>>   name = pci_fpga;
>>   common = startlib/board/pci_fpga.c;
>>   enable = efi;
>> };
>>
>> module = {
>>   name = pci_fpga_emul;
>>   common = startlib/board/pci_fpga_emul.c;
>>   enable = efi;
>> };
>> ...
>>
>> but then I get duplicate symbols error even without giving pci_fpga or
>> pci_fpga_emul on the build.
>>
>> For using different packages than 'common' like this
>> module = {
>>   name = pci_fpga;
>>   pci_fpga = startlib/board/pci_fpga.c;
>>   enable = efi;
>> };
>> I could not find means to get pci_fpga included.
>>
>> Same problem if trying to approach it via different enable flag: How to do?
>>
>> Can anybody help? In docs I couldn't find usable hints.
>>
>> --
>> KR
>> Michael
>>
>> ___
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>
>
>

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Need help: alternative module inclusion - duplicate symbols

2024-02-26 Thread Michael Lawnick via Grub-devel
Hi group,

hope you can help me:
I have modules pci_fpga.c and pci_fpga_emul.c with same functions in
them but different implementation, one for the real device, the other
one is just emulating.

What I now want is being able to include one of both versions through
build command. I started with this:

Makefile.core.def:
...
module = {
  name = pci_fpga;
  common = startlib/board/pci_fpga.c;
  enable = efi;
};

module = {
  name = pci_fpga_emul;
  common = startlib/board/pci_fpga_emul.c;
  enable = efi;
};
...

but then I get duplicate symbols error even without giving pci_fpga or
pci_fpga_emul on the build.

For using different packages than 'common' like this
module = {
  name = pci_fpga;
  pci_fpga = startlib/board/pci_fpga.c;
  enable = efi;
};
I could not find means to get pci_fpga included.

Same problem if trying to approach it via different enable flag: How to do?

Can anybody help? In docs I couldn't find usable hints.

--
KR
Michael

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel