Skip to content
Snippets Groups Projects

WIP: Avoid any use of Vc-detected CXX flags

Closed Jö Fahlke requested to merge avoid-any-vc-cxx-flags into master

Addresses: docker/ci#9 (comment 56350)

WIP:

  • Check this similar to !677 (comment 56357)
  • Check whether there are -fabi-version issues in older, still supported compilers
  • changelog entry (deferred to #163 (closed))
Edited by Jö Fahlke

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Jö Fahlke mentioned in merge request !677 (merged)

    mentioned in merge request !677 (merged)

  • Jö Fahlke marked the checklist item Check this similar to !677 (comment 56357) as completed

    marked the checklist item Check this similar to !677 (comment 56357) as completed

  • Jö Fahlke changed the description

    changed the description

  • Jö Fahlke mentioned in issue docker/ci#9

    mentioned in issue docker/ci#9

  • mentioned in issue #163 (closed)

  • Jö Fahlke mentioned in commit 19557065

    mentioned in commit 19557065

  • Jö Fahlke changed the description

    changed the description

  • Author Owner

    regarding the -fabi-version flag:

    So this is needed because without it, two declarations

    void func(__m128);
    void func(__m256);

    would have the same mangled name and could not be destinguished by the linker.

  • Author Owner

    The -ffp-contract=fast is from https://github.com/VcDevel/Vc/commit/3bd25129f6a3148c8368c0a443f7cd9a963a6612 with the comment:

    use -ffp-contract=fast if the compiler recognizes it to generate FMAs

    I suppose that should actually be left to the user and not decided by Vc

  • Author Owner

    And the -Wabi flag also is something that should be left to whoever is compiling.

    I do think that it is somewhat OK for Vc to set the -fabi-version flags, as without the correct abi version it is impossible to use Vc. It would be better though to detect the abi version and error out if it is insufficient -- this way the user would still have the option to select the precise abi version if there are other constraints imposed by unrelated libraries.

  • Author Owner

    We currently support gcc 5 and clang 3.8.

    In gcc 5 (ubuntu 16.04) we have:

    '-fabi-version=N'
         Use version N of the C++ ABI.  The default is version 0.
    [...]
    '-fabi-compat-version=N'
         On targets that support strong aliases, G++ works around mangling
         changes by creating an alias with the correct mangled name when
         defining a symbol with an incorrect mangled name.  This switch
         specifies which ABI version to use for the alias.
    
         With '-fabi-version=0' (the default), this defaults to 2.  If
         another ABI version is explicitly selected, this defaults to 0.

    So, if we'd leave these options out with gcc 5, -fabi-compat-version would default to 2, promting gcc to generate aliases for that abi-version. That may be a problem, because the aliases for entities overloaded on __m128 and __m256 would clash.

  • Author Owner

    With gcc 6, the default for -fabi-compat-version becomes 8.

  • Author Owner

    With clang, Vc does not seem to detect the abi-version flags. Instead it uses these flags (clang 6 on ubuntu 18.04):

    Vc_COMPILE_FLAGS=<-Wno-local-type-template-args;-Wno-unnamed-type-template-args;-ffp-contract=fast>
  • Author Owner

    Same flags detected with clang 3.8.1 on debian stretch.

  • Author Owner

    AFAICT, using local or unnamed types as template arguments is OK since C++11, see https://stackoverflow.com/questions/5751977/local-type-as-template-arguments-in-c. So these options should be fine

  • Author Owner

    Trying this MR out on gcc 5/debian jessie runs the tests successfully. So it seems that leaving the abi-version options off is fine.

    I'm guessing for this to become a problem you'd need to actually use symbols containing __m128 or __m256 across translation units, such as when compiling them into a library. The tests kind-off do that, they explicitly instantiate tests for different Vc vectors -- just they only ever do that for one abi, i.e. they nether try to mix Vc::Vector for SSE and AVX abis. I should be able to unit-test that explicitly.

  • Author Owner

    It seems that indeed it is possible to trigger the error the abi-version options are meant to prevent:

    Step 9/10 : RUN g++ -std=c++11 -march=native -Wabi *.cc -o test
     ---> Running in 3063a44c6941
    /tmp/cc37cpHp.o: In function `test(float __vector(8))':
    test-m256.cc:(.text+0x0): multiple definition of `test(float __vector)'
    /tmp/ccLx6o0e.o:test-m128.cc:(.text+0x0): first defined here
    collect2: error: ld returned 1 exit status
    The command '/bin/sh -c g++ -std=c++11 -march=native -Wabi *.cc -o test' returned a non-zero code: 1

    That was on epic, which supports avx2. The container was with ubuntu 16:04 and g++ (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609

    Docker context:

  • Author Owner

    Well, under this circumstance I think it is not a good idea to skip the Vc_COMPILE_FLAGS. I'm going to close this MR, we can reconsider when we drop support for gcc 5.

  • closed

Please register or sign in to reply
Loading