<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Thread Sanitizer link error in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733595#M178025</link>
    <description>&lt;P&gt;Here's a minimal example (a translation of C++ example from Intel) to reproduce the error. When attempting to compile into library using the following command&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;ifx -shared -fPIC -fsanitize=thread -o libmergesort.so mergeSortMod.f90&lt;/LI-CODE&gt;&lt;P&gt;I get the following errors:&lt;/P&gt;&lt;BLOCKQUOTE&gt;" ...&amp;nbsp;libclang_rt.tsan.a(tsan_interceptors_posix.cpp.o): relocation R_X86_64_TPOFF32 against `_ZL10pglob_copy' can not be used when making a shared object; recompile with -fPIC"&lt;BR /&gt;" ...&amp;nbsp;libclang_rt.tsan.a(tsan_rtl.cpp.o): relocation R_X86_64_TPOFF32 against hidden symbol `_ZN6__tsan22cur_thread_placeholderE' can not be used when making a shared object"&lt;BR /&gt;"...&amp;nbsp;libclang_rt.tsan.a(tsan_preinit.cpp.o): .preinit_array section is not allowed in DSO"&lt;BR /&gt;"ld: failed to set dynamic section sizes: Nonrepresentable section on output"&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="fortran"&gt;! Fortran Implementation of Intel C++ Code Example
module MergeSortModule
  use omp_lib
  implicit none
  integer, parameter :: task_threshold = 5000  ! Threshold for creating OpenMP tasks
  integer :: my_counter = 0  ! Counter to track function calls
contains

  ! Description: Initializes the array and shuffles the elements.
  subroutine InitializeArray(a, n)
    integer, intent(inout) :: a(:)
    integer, intent(in) :: n
    integer :: i, tmp, j

    ! Initialize the array
    do i = 1, n
      a(i) = i - 1
    end do

    print *, "Shuffling the array"

    ! Shuffle the array (Fisher-Yates Shuffle Algorithm)
    call random_seed()
    do i = n, 2, -1
      call random_number(tmp)
      j = floor(tmp * real(i)) + 1
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
    end do
  end subroutine InitializeArray

  ! Description: Checks if the array is correctly sorted
  function CheckArray(a, n) result(error_flag)
    integer, intent(in) :: a(:)
    integer, intent(in) :: n
    integer :: i, error_flag

    error_flag = 0  ! Assume no errors

    do i = 1, n - 1
      if (a(i) &amp;gt;= a(i + 1) .or. a(i) /= (i - 1)) then
        print *, "Sort failed at location", i, ", a(i)=", a(i), " a(i+1)=", a(i + 1)
        error_flag = 1
        return
      end if
    end do
  end function CheckArray

  ! Description: Merges two sublists of the array
  subroutine Merge(a, tmp_a, first, middle, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, middle, last
    integer :: p1, p2, p, i

    p1 = first
    p2 = middle
    p = first

    ! Merge two portions of the array into the temporary array
    do while (p &amp;lt;= last)
      if (p1 &amp;lt; middle .and. (p2 &amp;gt; last .or. a(p1) &amp;lt; a(p2))) then
        tmp_a(p) = a(p1)
        p1 = p1 + 1
      else
        tmp_a(p) = a(p2)
        p2 = p2 + 1
      end if
      p = p + 1
    end do

    ! Copy the sorted portion back to the original array
    do i = first, last
      a(i) = tmp_a(i)
    end do
  end subroutine Merge

  ! Description: Recursive MergeSort algorithm
  recursive subroutine MergeSort(a, tmp_a, first, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, last
    integer :: middle

    if (first &amp;lt; last) then
      middle = (first + last + 1) / 2
      call MergeSort(a, tmp_a, first, middle - 1)
      call MergeSort(a, tmp_a, middle, last)
      call Merge(a, tmp_a, first, middle, last)
    end if
  end subroutine MergeSort

  ! Description: OpenMP Task-based version of MergeSort
  recursive subroutine MergeSortOpenMP(a, tmp_a, first, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, last
    integer :: middle

    if (first &amp;lt; last) then
      middle = (first + last + 1) / 2

      if (last - first &amp;lt; task_threshold) then
        call MergeSort(a, tmp_a, first, middle - 1)
        call MergeSort(a, tmp_a, middle, last)
      else
!$omp task
        call MergeSortOpenMP(a, tmp_a, first, middle - 1)
!$omp task
        call MergeSortOpenMP(a, tmp_a, middle, last)
!$omp taskwait
      end if

      call Merge(a, tmp_a, first, middle, last)
      my_counter = my_counter + 1
    end if
  end subroutine MergeSortOpenMP

end module MergeSortModule&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jan 2026 03:32:21 GMT</pubDate>
    <dc:creator>vikramb</dc:creator>
    <dc:date>2026-01-15T03:32:21Z</dc:date>
    <item>
      <title>Thread Sanitizer link error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733572#M178023</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Intel IFX 2024.2 compiler on Linux.&amp;nbsp;I am trying to build my executable and dynamic libraries (on Linux) with thread sanitizer instrumented to detect data races. I am using '-fsanitize=thread' flags for both compiling as well as linking. However when I attempt to build any shared library I get linking errors like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;" ...&amp;nbsp;libclang_rt.tsan.a(tsan_interceptors_posix.cpp.o): relocation R_X86_64_TPOFF32 against `_ZL10pglob_copy' can not be used when making a shared object; recompile with -fPIC"&lt;/P&gt;&lt;P&gt;" ...&amp;nbsp;libclang_rt.tsan.a(tsan_rtl.cpp.o): relocation R_X86_64_TPOFF32 against hidden symbol `_ZN6__tsan22cur_thread_placeholderE' can not be used when making a shared object"&lt;/P&gt;&lt;P&gt;" ...&amp;nbsp;libclang_rt.tsan.a(tsan_preinit.cpp.o): .preinit_array section is not allowed in DSO"&lt;/P&gt;&lt;P&gt;"ld: failed to set dynamic section sizes: Nonrepresentable section on output"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All my libraries have the '-fPIC' compile flag. So I think the issue is with the TSAN runtime library included with the compiler. How can can I avoid these errors?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2026 22:17:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733572#M178023</guid>
      <dc:creator>vikramb</dc:creator>
      <dc:date>2026-01-14T22:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Thread Sanitizer link error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733573#M178024</link>
      <description>&lt;P&gt;If there is a way to link against the shared version of the library (&lt;SPAN&gt;libclang_rt.tsan.so) will this problem go away?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2026 22:18:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733573#M178024</guid>
      <dc:creator>vikramb</dc:creator>
      <dc:date>2026-01-14T22:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Thread Sanitizer link error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733595#M178025</link>
      <description>&lt;P&gt;Here's a minimal example (a translation of C++ example from Intel) to reproduce the error. When attempting to compile into library using the following command&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;ifx -shared -fPIC -fsanitize=thread -o libmergesort.so mergeSortMod.f90&lt;/LI-CODE&gt;&lt;P&gt;I get the following errors:&lt;/P&gt;&lt;BLOCKQUOTE&gt;" ...&amp;nbsp;libclang_rt.tsan.a(tsan_interceptors_posix.cpp.o): relocation R_X86_64_TPOFF32 against `_ZL10pglob_copy' can not be used when making a shared object; recompile with -fPIC"&lt;BR /&gt;" ...&amp;nbsp;libclang_rt.tsan.a(tsan_rtl.cpp.o): relocation R_X86_64_TPOFF32 against hidden symbol `_ZN6__tsan22cur_thread_placeholderE' can not be used when making a shared object"&lt;BR /&gt;"...&amp;nbsp;libclang_rt.tsan.a(tsan_preinit.cpp.o): .preinit_array section is not allowed in DSO"&lt;BR /&gt;"ld: failed to set dynamic section sizes: Nonrepresentable section on output"&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="fortran"&gt;! Fortran Implementation of Intel C++ Code Example
module MergeSortModule
  use omp_lib
  implicit none
  integer, parameter :: task_threshold = 5000  ! Threshold for creating OpenMP tasks
  integer :: my_counter = 0  ! Counter to track function calls
contains

  ! Description: Initializes the array and shuffles the elements.
  subroutine InitializeArray(a, n)
    integer, intent(inout) :: a(:)
    integer, intent(in) :: n
    integer :: i, tmp, j

    ! Initialize the array
    do i = 1, n
      a(i) = i - 1
    end do

    print *, "Shuffling the array"

    ! Shuffle the array (Fisher-Yates Shuffle Algorithm)
    call random_seed()
    do i = n, 2, -1
      call random_number(tmp)
      j = floor(tmp * real(i)) + 1
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
    end do
  end subroutine InitializeArray

  ! Description: Checks if the array is correctly sorted
  function CheckArray(a, n) result(error_flag)
    integer, intent(in) :: a(:)
    integer, intent(in) :: n
    integer :: i, error_flag

    error_flag = 0  ! Assume no errors

    do i = 1, n - 1
      if (a(i) &amp;gt;= a(i + 1) .or. a(i) /= (i - 1)) then
        print *, "Sort failed at location", i, ", a(i)=", a(i), " a(i+1)=", a(i + 1)
        error_flag = 1
        return
      end if
    end do
  end function CheckArray

  ! Description: Merges two sublists of the array
  subroutine Merge(a, tmp_a, first, middle, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, middle, last
    integer :: p1, p2, p, i

    p1 = first
    p2 = middle
    p = first

    ! Merge two portions of the array into the temporary array
    do while (p &amp;lt;= last)
      if (p1 &amp;lt; middle .and. (p2 &amp;gt; last .or. a(p1) &amp;lt; a(p2))) then
        tmp_a(p) = a(p1)
        p1 = p1 + 1
      else
        tmp_a(p) = a(p2)
        p2 = p2 + 1
      end if
      p = p + 1
    end do

    ! Copy the sorted portion back to the original array
    do i = first, last
      a(i) = tmp_a(i)
    end do
  end subroutine Merge

  ! Description: Recursive MergeSort algorithm
  recursive subroutine MergeSort(a, tmp_a, first, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, last
    integer :: middle

    if (first &amp;lt; last) then
      middle = (first + last + 1) / 2
      call MergeSort(a, tmp_a, first, middle - 1)
      call MergeSort(a, tmp_a, middle, last)
      call Merge(a, tmp_a, first, middle, last)
    end if
  end subroutine MergeSort

  ! Description: OpenMP Task-based version of MergeSort
  recursive subroutine MergeSortOpenMP(a, tmp_a, first, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, last
    integer :: middle

    if (first &amp;lt; last) then
      middle = (first + last + 1) / 2

      if (last - first &amp;lt; task_threshold) then
        call MergeSort(a, tmp_a, first, middle - 1)
        call MergeSort(a, tmp_a, middle, last)
      else
!$omp task
        call MergeSortOpenMP(a, tmp_a, first, middle - 1)
!$omp task
        call MergeSortOpenMP(a, tmp_a, middle, last)
!$omp taskwait
      end if

      call Merge(a, tmp_a, first, middle, last)
      my_counter = my_counter + 1
    end if
  end subroutine MergeSortOpenMP

end module MergeSortModule&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jan 2026 03:32:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733595#M178025</guid>
      <dc:creator>vikramb</dc:creator>
      <dc:date>2026-01-15T03:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Thread Sanitizer link error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733597#M178026</link>
      <description>&lt;P&gt;There is small error in the call to random_number subroutine in the code snippet above. It needs a real argument 'rtmp' instead of integer 'tmp'. This needs to be declared as well.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jan 2026 03:36:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733597#M178026</guid>
      <dc:creator>vikramb</dc:creator>
      <dc:date>2026-01-15T03:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Thread Sanitizer link error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733598#M178027</link>
      <description>&lt;P&gt;The code snippet to reproduce the errors is below.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The command I tried is&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;ifx -shared -fPIC -fsanitize=thread -o libmergesort.so mergeSortMod.f90&lt;/LI-CODE&gt;&lt;LI-CODE lang="fortran"&gt;! Modern Fortran Implementation of the Given C++ Code
module MergeSortModule
  use omp_lib
  implicit none
  integer, parameter :: task_threshold = 5000  ! Threshold for creating OpenMP tasks
  integer :: my_counter = 0  ! Counter to track function calls
contains

  ! Description: Initializes the array and shuffles the elements.
  subroutine InitializeArray(a, n)
    integer, intent(inout) :: a(:)
    integer, intent(in) :: n
    integer :: i, tmp, j
	real :: rtmp

    ! Initialize the array
    do i = 1, n
      a(i) = i - 1
    end do

    print *, "Shuffling the array"

    ! Shuffle the array (Fisher-Yates Shuffle Algorithm)
    call random_seed()
    do i = n, 2, -1
      call random_number(rtmp)
      j = floor(rtmp * real(i)) + 1
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
    end do
  end subroutine InitializeArray

  ! Description: Checks if the array is correctly sorted
  function CheckArray(a, n) result(error_flag)
    integer, intent(in) :: a(:)
    integer, intent(in) :: n
    integer :: i, error_flag

    error_flag = 0  ! Assume no errors

    do i = 1, n - 1
      if (a(i) &amp;gt;= a(i + 1) .or. a(i) /= (i - 1)) then
        print *, "Sort failed at location", i, ", a(i)=", a(i), " a(i+1)=", a(i + 1)
        error_flag = 1
        return
      end if
    end do
  end function CheckArray

  ! Description: Merges two sublists of the array
  subroutine Merge(a, tmp_a, first, middle, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, middle, last
    integer :: p1, p2, p, i

    p1 = first
    p2 = middle
    p = first

    ! Merge two portions of the array into the temporary array
    do while (p &amp;lt;= last)
      if (p1 &amp;lt; middle .and. (p2 &amp;gt; last .or. a(p1) &amp;lt; a(p2))) then
        tmp_a(p) = a(p1)
        p1 = p1 + 1
      else
        tmp_a(p) = a(p2)
        p2 = p2 + 1
      end if
      p = p + 1
    end do

    ! Copy the sorted portion back to the original array
    do i = first, last
      a(i) = tmp_a(i)
    end do
  end subroutine Merge

  ! Description: Recursive MergeSort algorithm
  recursive subroutine MergeSort(a, tmp_a, first, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, last
    integer :: middle

    if (first &amp;lt; last) then
      middle = (first + last + 1) / 2
      call MergeSort(a, tmp_a, first, middle - 1)
      call MergeSort(a, tmp_a, middle, last)
      call Merge(a, tmp_a, first, middle, last)
    end if
  end subroutine MergeSort

  ! Description: OpenMP Task-based version of MergeSort
  recursive subroutine MergeSortOpenMP(a, tmp_a, first, last)
    integer, intent(inout) :: a(:), tmp_a(:)
    integer, intent(in) :: first, last
    integer :: middle

    if (first &amp;lt; last) then
      middle = (first + last + 1) / 2

      if (last - first &amp;lt; task_threshold) then
        call MergeSort(a, tmp_a, first, middle - 1)
        call MergeSort(a, tmp_a, middle, last)
      else
!$omp task
        call MergeSortOpenMP(a, tmp_a, first, middle - 1)
!$omp task
        call MergeSortOpenMP(a, tmp_a, middle, last)
!$omp taskwait
      end if

      call Merge(a, tmp_a, first, middle, last)
      my_counter = my_counter + 1
    end if
  end subroutine MergeSortOpenMP

end module MergeSortModule&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jan 2026 03:39:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733598#M178027</guid>
      <dc:creator>vikramb</dc:creator>
      <dc:date>2026-01-15T03:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Thread Sanitizer link error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733634#M178028</link>
      <description>&lt;P&gt;Somehow all previous attempts to include code inside have not worked. A minimal example source file is attached. The command I used is 'ifx -shared -fPIC&amp;nbsp;-fsanitize=thread -o libmergesort.so MergeSortModule.f90'.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jan 2026 14:12:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Thread-Sanitizer-link-error/m-p/1733634#M178028</guid>
      <dc:creator>vikramb</dc:creator>
      <dc:date>2026-01-15T14:12:48Z</dc:date>
    </item>
  </channel>
</rss>

