Hi,

Tristan Gingold wrote:
>> In some of our use of GHDL, we link the GHDL runtime with another
> - hide quoted text -- show quoted text -
>> executable in order to use the foreign language feature of GHDL. We
>> start the GHDL simulation in accordance with the GHDL manual by calling
>> ghdl_main(). This works fine on OS X, but on Linux the application fails
>> to link with a duplicate symbol error for main(). The problem seems to
>> be that the main symbol is present in libgrt. The problem can be fixed
>> by marking the main function in libgrt as weak:
> 
> How do you link your application ?  libgrt is provided as a static
> library, so its members are extracted only if needed.  Therefore, making
> main weak shouldn't be required.

We use the following when linking:
$GHDL --bind $GHDL_OPTIONS $TARGET
$CC `$GHDL --list-link $GHDL_OPTIONS $TARGET` -o $TARGET $C_OBJECTS

For linking an actual application this expands to a massive chunk:

/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/bin/ghdl
--bind --workdir=work_regtest --ieee=synopsys -g tinuso_grid

gcc work_regtest/e~tinuso_grid.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/std/std_standard.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/synopsys/std_logic_1164.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/synopsys/std_logic_1164_body.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/synopsys/numeric_std.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/synopsys/numeric_std-body.o
work_regtest/pkg_tinuso_function.o work_regtest/tinuso_grid.o
work_regtest/pkg_noc_function.o work_regtest/pkg_tinuso_ni_function.o
work_regtest/pkg_tinuso_mem.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/std/textio.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/std/textio_body.o
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//v93/synopsys/std_logic_textio.o
work_regtest/pkg_tinuso_sim.o work_regtest/regtest.o
work_regtest/sim_mem_core.o work_regtest/router_arb.o
work_regtest/pkg_tinuso_combinatorics.o
work_regtest/core_tinuso_pipeline.o work_regtest/tinuso_single_core_if.o
work_regtest/tinuso_ni.o -g
/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//libgrt.a
-ldl -lm
-Wl,--version-script=/home/s062068/.jenkins/jobs/master-tinuso-regression-simulator/workspace/gcc-4.9.2-ghdl-0.32-install/lib/gcc/x86_64-pc-linux-gnu/4.9.2/vhdl/lib//grt.ver
-Wl,--export-dynamic -L./ -lz -o tinuso_grid src/sim/grid_sim.o
src/sim/slave_32.o src/sim/elf.o src/sim/tinuso_uart_tx.o
src/sim/ghdl_env.o src/sim/axi_slave_local_mem.o src/sim/init_mem.o

main() is present in grid_sim.o, which causes a duplicate symbol error
if main in libgrt.a is not marked weak.

-- 
Best regards,
Andreas Hindborg
PhD Student
DTU Compute


_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to