Subject: Confusing (maybe wrong?) conflict output with ort

From: "Alex Xu (Hello71)" <[email-masked]>
Date: Thu, 02 Dec 2021 14:08:20 -0500

Hi all,

After upgrading to git 2.34.1, I tried to rebase [0] onto [1], but 
encountered "strange" conflict results.

git rebase -s recursive main produces [[RECURSIVE]]. It is roughly what 
I expected to be output. If I take all the changes from the upper 
section of the conflict, my changes will be effectively undone. If I 
take all the changes from the lower section, then the upstream changes 
will be undone.

On the other hand, running git rebase -s ort main produces [[ORT]]. I am 
unsure if it is wrong, strictly speaking, but it is certainly unexpected 
and difficult for me to resolve. Selecting the upper section of the 
conflict does erase my changes, as before, but selecting the lower 
section results in syntactically incorrect code (foreach is ended by 
endif). The diff3 output makes even less sense to me.

A script is attached to assist in reproducing my results. Running it 
initializes the repository to the desired state. Then, run "git rebase 
-s strategy master" to produce the conflict.

Thanks,
Alex.

[0] https://gitlab.freedesktop.org/alxu/mesa/-/commit/4ad18ab613101e3489ca2d9e7151125f670e1ea5
[1] https://gitlab.freedesktop.org/alxu/mesa/-/commit/c47fd3dc0062101b3e75a414b17d2765735f7424

[[RECURSIVE]]

<<<<<<< HEAD
use_elf_tls = true
pre_args += '-DUSE_ELF_TLS'

if with_platform_android and get_option('platform-sdk-version') >= 29
  # By default the NDK compiler, at least, emits emutls references instead of
  # ELF TLS, even when building targeting newer API levels.  Make it actually do
  # ELF TLS instead.
  c_args += '-fno-emulated-tls'
  cpp_args += '-fno-emulated-tls'
endif

# -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires
# full toolchain (including libc) support.
have_mtls_dialect = false
foreach c_arg : get_option('c_args')
  if c_arg.startswith('-mtls-dialect=')
    have_mtls_dialect = true
    break
  endif
endforeach
if not have_mtls_dialect
  # need .run to check libc support. meson aborts when calling .run when
  # cross-compiling, but because this is just an optimization we can skip it
  if meson.is_cross_build()
    warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
  else
    # -fpic to force dynamic tls, otherwise TLS relaxation defeats check
    gnu2_test = cc.run('int __thread x; int main() { return x; }', args: ['-mtls-dialect=gnu2', '-fpic'], name: '-mtls-dialect=gnu2')
    if gnu2_test.returncode() == 0
      c_args += '-mtls-dialect=gnu2'
      cpp_args += '-mtls-dialect=gnu2'
=======
use_elf_tls = false
if not with_platform_windows or not with_shared_glapi
  pre_args += '-DUSE_ELF_TLS'
  use_elf_tls = true

  if with_platform_android and get_option('platform-sdk-version') >= 29
    # By default the NDK compiler, at least, emits emutls references instead of
    # ELF TLS, even when building targeting newer API levels.  Make it actually do
    # ELF TLS instead.
    c_args += '-fno-emulated-tls'
    cpp_args += '-fno-emulated-tls'
  endif

  # -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires
  # full toolchain (including libc) support.
  have_mtls_dialect = false
  foreach c_arg : get_option('c_args')
    if c_arg.startswith('-mtls-dialect=')
      have_mtls_dialect = true
      break
    endif
  endforeach
  if not have_mtls_dialect
    # need .run to check libc support. meson aborts when calling .run when
    # cross-compiling, but because this is just an optimization we can skip it
    if meson.is_cross_build()
      warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
    else
      # -fpic to force dynamic tls, otherwise TLS relaxation defeats check
      gnu2_test = cc.run('int __thread x; int main() { return x; }', args: ['-mtls-dialect=gnu2', '-fpic'], name: '-mtls-dialect=gnu2')
      # https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
      if gnu2_test.returncode() == 0 and (
           host_machine.cpu_family() != 'x86_64' or
           # https://github.com/mesonbuild/meson/issues/6377
           #cc.get_linker_id() != 'ld.lld' or
           cc.links('''int __thread x; int y; int main() { __asm__(
                  "leaq x@TLSDESC(%rip), %rax\n"
                  "movq y@GOTPCREL(%rip), %rdx\n"
                  "call *x@TLSCALL(%rax)\n"); }''', name: 'split TLSDESC')
           )
        c_args += '-mtls-dialect=gnu2'
        cpp_args += '-mtls-dialect=gnu2'
      endif
>>>>>>> 4ad18ab6131 (meson: check for lld split TLSDESC bug (fixes #5665))
    endif
  endif
endif

[[ORT]]

# -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires
# full toolchain (including libc) support.
have_mtls_dialect = false
foreach c_arg : get_option('c_args')
  if c_arg.startswith('-mtls-dialect=')
    have_mtls_dialect = true
    break
  endif
<<<<<<< HEAD
endforeach
if not have_mtls_dialect
  # need .run to check libc support. meson aborts when calling .run when
  # cross-compiling, but because this is just an optimization we can skip it
  if meson.is_cross_build()
    warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
  else
    # -fpic to force dynamic tls, otherwise TLS relaxation defeats check
    gnu2_test = cc.run('int __thread x; int main() { return x; }', args: ['-mtls-dialect=gnu2', '-fpic'], name: '-mtls-dialect=gnu2')
    if gnu2_test.returncode() == 0
      c_args += '-mtls-dialect=gnu2'
      cpp_args += '-mtls-dialect=gnu2'
=======

  # -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires
  # full toolchain (including libc) support.
  have_mtls_dialect = false
  foreach c_arg : get_option('c_args')
    if c_arg.startswith('-mtls-dialect=')
      have_mtls_dialect = true
      break
    endif
  endforeach
  if not have_mtls_dialect
    # need .run to check libc support. meson aborts when calling .run when
    # cross-compiling, but because this is just an optimization we can skip it
    if meson.is_cross_build()
      warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
    else
      # -fpic to force dynamic tls, otherwise TLS relaxation defeats check
      gnu2_test = cc.run('int __thread x; int main() { return x; }', args: ['-mtls-dialect=gnu2', '-fpic'], name: '-mtls-dialect=gnu2')
      # https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
      if gnu2_test.returncode() == 0 and (
           host_machine.cpu_family() != 'x86_64' or
           # https://github.com/mesonbuild/meson/issues/6377
           #cc.get_linker_id() != 'ld.lld' or
           cc.links('''int __thread x; int y; int main() { __asm__(
                  "leaq x@TLSDESC(%rip), %rax\n"
                  "movq y@GOTPCREL(%rip), %rdx\n"
                  "call *x@TLSCALL(%rax)\n"); }''', name: 'split TLSDESC')
           )
        c_args += '-mtls-dialect=gnu2'
        cpp_args += '-mtls-dialect=gnu2'
      endif
>>>>>>> 4ad18ab6131 (meson: check for lld split TLSDESC bug (fixes #5665))
    endif
  endif
endif