https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116803

            Bug ID: 116803
           Summary: Linkage fails if modules are compiled in a certain
                    order
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at richy dot net
  Target Milestone: ---

richard@microserver:~/scratch/broken> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/richard/gcc/lib/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --host=x86_64-pc-linux-gnu
--prefix=/home/richard/gcc --enable-threads --enable-language=c,c++
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.0 20240917 (experimental) (GCC) 

richard@microserver:~/scratch/broken> g++ -std=c++2b -fmodules-ts -fconcepts
-Wall -O3 -g -save-temps -fPIC -x c++-system-header algorithm
richard@microserver:~/scratch/broken> g++ -std=c++2b -fmodules-ts -fconcepts
-Wall -O3 -g -save-temps -fPIC -x c++-system-header execution
richard@microserver:~/scratch/broken>  g++ -std=c++2b -fmodules-ts -fconcepts
-Wall -O3 -g -save-temps -fPIC -x c++-system-header vector
richard@microserver:~/scratch/broken> g++ -std=c++2b -fmodules-ts -fconcepts
-Wall -O3 -g -fPIC -save-temps -c ./example.cpp -o example.o
richard@microserver:~/scratch/broken>  g++ -std=c++2b -fmodules-ts -fconcepts
-Wall -O3 -g -fPIC -save-temps -o ./example ./example.o
/usr/bin/ld: ./example.o: in function `main':
/home/richard/scratch/broken/./example.cpp:10:(.text.startup+0x10): undefined
reference to
`std::enable_if<__pstl::execution::v1::is_execution_policy<std::remove_cv<std::remove_reference<__pstl::execution::v1::parallel_unsequenced_policy
const&>::type>::type>::value, void>::type
std::sort<__pstl::execution::v1::parallel_unsequenced_policy const&,
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >
>(__pstl::execution::v1::parallel_unsequenced_policy const&,
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >,
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >)'
collect2: error: ld returned 1 exit status

If the algorithm module is built after the vector module, it will link
correctly. Sample code below, *.ii files attached.

import <algorithm>;
import <execution>;
import <vector>;

using namespace std;

int main()
{
  vector<int> arr{};
  sort(execution::par_unseq, arr.begin(), arr.end());

  return 0;
}


Note this also breaks on 14.2.0 as provided via the docker container. This
15.0.0 is a hand-build for testing if the bug appeared on the trunk.

Reply via email to