Package: systemc
Severity: normal

Dear Maintainer,

libsystemc.so actually provided in testing (forky) and unstable is built using the C++17 standard which is the default for g++ in stable (trixie). It seems that the default for g++ in testing is now C++20 which leads to linkage errors when using g++ defaults (without specifying std=c++17 in CXXFLAGS).

TL;DR could you please re-upload the libsystemc-dev package for testing after a rebuilt with default g++ options.


----

Simple test:

```
echo -e '#include<systemc>\nint sc_main(int,char**){return 0;}' | g++ -x c++ -lsystemc -
```

works on stable (trixie) but fails on testing (forky) with the following:

```
/usr/bin/x86_64-linux-gnu-ld.bfd: /tmp/ccOZens0.o: in function `__static_initialization_and_destruction_0()': <stdin>:(.text+0x2b): undefined reference to `sc_core::sc_api_version_3_0_2_cxx202002L::sc_api_version_3_0_2_cxx202002L(sc_core::sc_writer_policy, bool)'
collect2: error: ld returned 1 exit status
```

Forcing the C++ version solve the issue. i.e. :

```
echo -e '#include<systemc>\nint sc_main(int,char**){return 0;}' | g++ --std=c++17 -x c++ -lsystemc -
```

This is due to the fact that systemc creates the sc_api object to be sure that the same options have been used to build the library and the final executable. The name of this object is constructed using the __cplusplus g++ predefined macro.

The default value can be found, for example, with the following command:

```
echo __cplusplus | g++ -E -x c++  - | grep 20
```

Which gives in stable (trixie) `201703L` (default C++17) while in testing (forky) we get `202002L` (default C++20).

This macro is used to initialize SC_CPLUSPLUS macro in systemc headers and to construct the sc_api object.

---

Regarding systemc and the IEEE Std. 1666-2023 standard...
The standard mandates "C++17 as the baseline for SystemC" as indicated here:

https://github.com/accellera-official/systemc/blob/main/RELEASENOTES.md#6-c17-support

But, more recent versions of C++ are also supported. The documentation says "Compiling this implementation for newer C++ standards is generally possible and tested at a best effort basis."

And C++20 (and even 23) is already recognized by the build system as indicated here:

https://github.com/accellera-official/systemc/blob/main/docs/INSTALL_USING_AUTOTOOLS.md#preprocessor-switches

---

I personally think that, for the Debian package, using g++ defaults is the best option, as it allows to use the library without additional compilation options. If somebody needs full IEEE conformance it will be easy for him to rebuild the library with different options.

Finally, I have rebuilt the Debian package from source on testing, with g++ defaults (checked that C++20 is used) without changing anything to the package sources, and run all regression tests without issue.

If needed:

```
# before rebuild
 objdump -TC /usr/lib/x86_64-linux-gnu/libsystemc-3.0.2.so | grep sc_api
00000000000d24c0 g DF .text 00000000000000af Base sc_core::sc_api_version_3_0_2_cxx201703L::sc_api_version_3_0_2_cxx201703L(sc_core::sc_writer_policy, bool)
# after rebuild
 objdump -TC /usr/lib/x86_64-linux-gnu/libsystemc-3.0.2.so | grep sc_api
00000000000dac10 g DF .text 00000000000000b0 Base sc_core::sc_api_version_3_0_2_cxx202002L::sc_api_version_3_0_2_cxx202002L(sc_core::sc_writer_policy, bool)


Tarik

Reply via email to