Emulator Issues #11047
closedCompilation problems in Fedora 28 / GCC 8 / C++17
Added by lucag_73 over 6 years ago. Updated almost 6 years ago.
0%
Description
Hello,
I have found some compilation issues on Fedora 28
- the function _xgetbv(u32 index) is now defined in a system header file; I had to disable the inclusion of such file with a
#define _XSAVEINTRIN_H_INCLUDED
in Source/Core/Common/x64CPUDetect.cpp - there is some incompatibility between the way c++17 is implemented by gcc 8 and what is in Source/Core/DiscIO/VolumeGC.cpp
I had to force -std=c++14 in order to complete compilation
With these two changes I managed to get a runnable version of dolphin (6e62d1ab9f70bffef612d1c6c6bcfbc2958af2a6), however I understand that the code should get somehow fixed.
Updated by JosJuice over 6 years ago
- Tracker changed from Issue to Emulator Issues
- Project changed from Infrastructure to Emulator
- Issue type set to Bug
- Regression set to No
- Relates to usability set to No
- Relates to performance set to No
- Easy set to No
- Relates to maintainability set to No
- Operating system N/A added
Updated by leoetlino over 6 years ago
It would be useful to have the actual errors for issue 2 so we can determine if this is actually an issue we can fix.
Updated by lucag_73 over 6 years ago
Sure. Here they are.
- The error for issue 1 is:
/home/lucag/Src/EMU/dolphin/Source/Core/Common/x64CPUDetect.cpp:41:12: error: ambiguating new declaration of ‘u64 _xgetbv(u32)’
static u64 _xgetbv(u32 index)
^~~~~~~
In file included from /usr/lib/gcc/x86_64-redhat-linux/8/include/x86intrin.h:74,
from /home/lucag/Src/EMU/dolphin/Source/Core/Common/Intrinsics.h:30,
from /home/lucag/Src/EMU/dolphin/Source/Core/Common/x64CPUDetect.cpp:10:
/usr/lib/gcc/x86_64-redhat-linux/8/include/xsaveintrin.h:60:1: note: old declaration ‘long long int _xgetbv(unsigned int)’
_xgetbv (unsigned int __A)
^~~~~~~
/home/lucag/Src/EMU/dolphin/Source/Core/Common/x64CPUDetect.cpp:41:12: warning: ‘u64 _xgetbv(u32)’ defined but not used [-Wunused-function]
static u64 _xgetbv(u32 index)
- As for issue 2, this is what I get:
In file included from /home/lucag/Src/EMU/dolphin/Source/Core/Common/Compat/variant:8,
from /home/lucag/Src/EMU/dolphin/Source/Core/Common/Lazy.h:9,
from /home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.h:14,
from /home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.cpp:27:
/usr/include/c++/8/variant: In instantiation of ‘void std::__detail::__variant::__erased_assign(void*, void*) [with _Lhs = std::unique_ptrDiscIO::FileSystem&; _Rhs = const std::unique_ptrDiscIO::FileSystem&]’:
/usr/include/c++/8/variant:604:27: required from ‘std::__detail::__variant::_Move_assign_base<, _Types>& std::__detail::__variant::_Move_assign_base<, _Types>::operator=(std::__detail::__variant::_Move_assign_base<, _Types>&&) [with bool = false; _Types = {std::unique_ptr<DiscIO::FileSystem, std::default_deleteDiscIO::FileSystem >, std::function<std::unique_ptr<DiscIO::FileSystem, std::default_deleteDiscIO::FileSystem >()>}]’
/usr/include/c++/8/variant:645:12: required from ‘const Common::Lazy& Common::Lazy::operator=(std::variant<T, std::function<T()> >&&) [with T = std::unique_ptrDiscIO::FileSystem]’
/home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.cpp:38:3: required from here
/usr/include/c++/8/variant:254:42: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = DiscIO::FileSystem; _Dp = std::default_deleteDiscIO::FileSystem]’
__variant::__ref_cast<_Lhs>(__lhs) = __variant::__ref_cast<_Rhs>(__rhs);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/memory:80,
from /home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.cpp:8:
/usr/include/c++/8/bits/unique_ptr.h:395:19: note: declared here
unique_ptr& operator=(const unique_ptr&) = delete;
^~~~~~~~
In file included from /home/lucag/Src/EMU/dolphin/Source/Core/Common/Compat/variant:8,
from /home/lucag/Src/EMU/dolphin/Source/Core/Common/Lazy.h:9,
from /home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.h:14,
from /home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.cpp:27:
/usr/include/c++/8/variant: In instantiation of ‘void std::__detail::__variant::__erased_ctor(void*, void*) [with _Lhs = std::unique_ptrDiscIO::FileSystem&; _Rhs = const std::unique_ptrDiscIO::FileSystem&]’:
/usr/include/c++/8/variant:465:30: required from ‘std::__detail::__variant::_Copy_ctor_base<, _Types>::_Copy_ctor_base(const std::__detail::__variant::_Copy_ctor_base<, _Types>&) [with bool = false; _Types = {std::unique_ptr<DiscIO::FileSystem, std::default_deleteDiscIO::FileSystem >, std::function<std::unique_ptr<DiscIO::FileSystem, std::default_deleteDiscIO::FileSystem >()>}]’
/usr/include/c++/8/variant:506:7: required from ‘std::__detail::__variant::_Move_assign_base<, _Types>& std::__detail::__variant::_Move_assign_base<, _Types>::operator=(std::__detail::__variant::_Move_assign_base<, _Types>&&) [with bool = false; _Types = {std::unique_ptr<DiscIO::FileSystem, std::default_deleteDiscIO::FileSystem >, std::function<std::unique_ptr<DiscIO::FileSystem, std::default_deleteDiscIO::FileSystem >()>}]’
/usr/include/c++/8/variant:645:12: required from ‘const Common::Lazy& Common::Lazy::operator=(std::variant<T, std::function<T()> >&&) [with T = std::unique_ptrDiscIO::FileSystem]’
/home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.cpp:38:3: required from here
/usr/include/c++/8/variant:242:7: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = DiscIO::FileSystem; _Dp = std::default_deleteDiscIO::FileSystem]’
::new (__lhs) _Type(__variant::__ref_cast<_Rhs>(__rhs));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/memory:80,
from /home/lucag/Src/EMU/dolphin/Source/Core/DiscIO/VolumeGC.cpp:8:
/usr/include/c++/8/bits/unique_ptr.h:394:7: note: declared here
unique_ptr(const unique_ptr&) = delete;
^~~~~~~~~~
make[2]: *** [Source/Core/DiscIO/CMakeFiles/discio.dir/build.make:271: Source/Core/DiscIO/CMakeFiles/discio.dir/VolumeGC.cpp.o] Error 1
Updated by jkms over 6 years ago
Same issue. Fresh install of Fedora 28. I was able to resolve item 1 as per lucag_73, but I couldn't figure out how to implement the fix for item 2.
Tried the following, but nothing worked for me (clearly I haven idea what I'm doing, but that's okay)
cmake -std=c++14 ..
CXXFLAGS+=-std=c++14 cmake ..
cmake -DCMAKE_CXX_FLAGS="-std=c++14" ..
Anyway, rolled back to Fedora 27 for the time being. Compile works perfectly there.
Updated by lucag_73 over 6 years ago
I have also been unable to force c++14 from command line.
What I did was to edit CMakeLists.txt replacing the stanza
check_and_add_flag(CXX17 -std=c++17)
if(NOT FLAG_CXX_CXX17)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
with just
check_and_add_flag(CXX17 -std=c++17)¶
if(NOT FLAG_CXX_CXX17)¶
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()¶
Updated by lucag_73 over 6 years ago
ops... I meant I commented/deleted the check_and_add_flag, as well as the conditional (the comment on if/endif should not be necessary; none the less...)
Updated by lucag_73 over 6 years ago
The file to edit is Source/CMakeLists.txt and the lines to delete, 21, 22 and 26
lucag_73 wrote:
ops... I meant I commented/deleted the check_and_add_flag, as well as the conditional (the comment on if/endif should not be necessary; none the less...)
Updated by jkms over 6 years ago
Thanks lucag_73. that worked.
for anyone stumbling on this looking for a "tl;dr:
$ git diff
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 652b5f5422..13907fbf82 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -18,12 +18,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
else()
# Enable C++17, but fall back to C++14 if it isn't available.
# CMAKE_CXX_STANDARD cannot be used here because we require C++14 or newer, not any standard.
- check_and_add_flag(CXX17 -std=c++17)
- if(NOT FLAG_CXX_CXX17)
+ # check_and_add_flag(CXX17 -std=c++17)
+ # if(NOT FLAG_CXX_CXX17)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
- endif()
+ # endif()
# These compat headers must not be in the include path when building with MSVC,
# because it currently does not support __has_include_next / #include_next.
diff --git a/Source/Core/Common/x64CPUDetect.cpp b/Source/Core/Common/x64CPUDetect.cpp
index 74d22b3e32..ad33a542a7 100644
--- a/Source/Core/Common/x64CPUDetect.cpp
+++ b/Source/Core/Common/x64CPUDetect.cpp
@@ -1,6 +1,7 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#define _XSAVEINTRIN_H_INCLUDED
#include <cstring>
#include <string>
Updated by lucag_73 over 6 years ago
Incidentally, I have had the same problem with _xgetbv in compiling pcsx2: https://github.com/PCSX2/pcsx2/issues/2417
The "trivial" patch to use the library version of _xgetbv has shown that there is actually also an issue with the way gcc 8 treats that instruction: https://github.com/PCSX2/pcsx2/pull/
Updated by KAMiKAZOW over 6 years ago
According to https://github.com/libretro/dolphin/issues/13#issuecomment-386243414 fixing the issue is weirdly easy -- it involves only adding two underscores.
Updated by JosJuice over 6 years ago
The _xgetbv issue should have been fixed by 5.0-7291 (https://dolphin-emu.org/download/dev/2ab51c73c6e384b55ac8b95891bcecc455fae0da/). Are you still having the VolumeGC.cpp issue when compiling the latest version of master?
Updated by lucag_73 over 6 years ago
Indeed; the issue with VolumeGC.cpp is still open when compiling with the default options (i.e. -std=c++17).
Updated by KAMiKAZOW over 6 years ago
More and more Linux distributions are migrating to GCC8. Would be cool if a real bugfix could make it into Dolphin.
Updated by Billiard26 almost 6 years ago
- Subject changed from Compilation problems in Fedora 28 to Compilation problems in Fedora 28 / GCC 8 / C++17
Updated by Billiard26 almost 6 years ago
- Related to Emulator Issues #11021: Dolphin does not compile with gcc-8 added
Updated by JosJuice almost 6 years ago
- Related to deleted (Emulator Issues #11021: Dolphin does not compile with gcc-8)
Updated by JosJuice almost 6 years ago
- Has duplicate Emulator Issues #11021: Dolphin does not compile with gcc-8 added
Updated by Billiard26 almost 6 years ago
I can't reproduce this with GCC 8.2.1 so it's hard to fix the issue.
Can someone with the issue try this potential fix? https://github.com/jordan-woyak/dolphin/commit/1782cd0dcf17db57cbe8d1261732f0de6950f781
Updated by KAMiKAZOW almost 6 years ago
All build targets seem to work: https://build.opensuse.org/package/show/home:KAMiKAZOW:Test/dolphin-emu (see the box on the right).
Updated by Billiard26 almost 6 years ago
- Status changed from New to Working as intended
Seems like a compiler bug that was fixed.
Updated by KAMiKAZOW almost 6 years ago
Just to clarify: I built your branch but I can try vanilla upstream as well.
Updated by Billiard26 almost 6 years ago
Ah. Yeah, please let me know if that works. :P
Updated by lucag_73 almost 6 years ago
Recent versions of the emulator work flawlessly (without the workaround in the CMakefile)
Actually I have also updated the compiler to gcc version 8.2.1 20181215 (Red Hat 8.2.1-6) (GCC), so, perhaps,
some fixes have been made there as well.
Updated by KAMiKAZOW almost 6 years ago
Vanilla Dolphin indeed builds fine under Fedora 28 now. So yeah, it was probably a GCC bug (or they've added a compatibility workaround).