paraview is failing to build on arm:
/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/CommandLineExecutables/paraview-config-forward.c:
In function '__cpuid':
/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/CommandLineExecutables/paraview-config-forward.c:95:3:
error: impossible constraint in 'asm'
asm volatile("cpuid" : "=a"(out[0]), "=b"(out[1]), "=c"(out[2]),
"=d"(out[3])
^
/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/CommandLineExecutables/paraview-config-forward.c:
In function 'check_xcr0_ymm':
/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/CommandLineExecutables/paraview-config-forward.c:124:3:
error: unknown register name '%edx' in 'asm'
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx");
^
/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/CommandLineExecutables/paraview-config-forward.c:
In function 'get_cpu_features':
/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/CommandLineExecutables/paraview-config-forward.c:124:3:
error: unknown register name '%edx' in 'asm'
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx");
^
Would someone familiar with arm assembly be willing to take a look?
Unfortunately this is a generated file, but I've attached at copy.
Does arm even implement cpuid?
Thanks.
--
Orion Poplawski
Technical Manager 303-415-9701 x222
NWRA, Boulder/CoRA Office FAX: 303-415-9702
3380 Mitchell Lane orion@xxxxxxxx
Boulder, CO 80301 http://www.nwra.com
/*=========================================================================
Program: ParaView
Module: pv-forward.c.in
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#define vtksys_SHARED_FORWARD_DIR_BUILD "/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/bin"
#define vtksys_SHARED_FORWARD_PATH_BUILD "/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/bin"
#define vtksys_SHARED_FORWARD_PATH_INSTALL "../lib/paraview"
#define vtksys_SHARED_FORWARD_EXE_BUILD "/builddir/build/BUILD/ParaView-v5.0.0-RC3-source/fedora/bin/paraview-config"
#define vtksys_SHARED_FORWARD_EXE_INSTALL "../lib/paraview/paraview-config"
#define vtksys_SHARED_FORWARD_OPTION_PRINT "--print"
#define vtksys_SHARED_FORWARD_OPTION_LDD "--ldd"
#include <vtksys/SharedForward.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>
/* CPU features */
static const int CPU_FEATURE_SSE = 1 << 0;
static const int CPU_FEATURE_SSE2 = 1 << 1;
static const int CPU_FEATURE_SSE3 = 1 << 2;
static const int CPU_FEATURE_SSSE3 = 1 << 3;
static const int CPU_FEATURE_SSE41 = 1 << 4;
static const int CPU_FEATURE_SSE42 = 1 << 5;
static const int CPU_FEATURE_POPCNT = 1 << 6;
static const int CPU_FEATURE_AVX = 1 << 7;
static const int CPU_FEATURE_F16C = 1 << 8;
static const int CPU_FEATURE_RDRAND = 1 << 9;
static const int CPU_FEATURE_AVX2 = 1 << 10;
static const int CPU_FEATURE_FMA3 = 1 << 11;
static const int CPU_FEATURE_LZCNT = 1 << 12;
static const int CPU_FEATURE_BMI1 = 1 << 13;
static const int CPU_FEATURE_BMI2 = 1 << 14;
static const int CPU_FEATURE_KNC = 1 << 15;
/* cpuid[eax=0].ecx */
static const int CPU_FEATURE_BIT_SSE3 = 1 << 0;
static const int CPU_FEATURE_BIT_SSSE3 = 1 << 9;
static const int CPU_FEATURE_BIT_FMA3 = 1 << 12;
static const int CPU_FEATURE_BIT_SSE4_1 = 1 << 19;
static const int CPU_FEATURE_BIT_SSE4_2 = 1 << 20;
static const int CPU_FEATURE_BIT_MOVBE = 1 << 22;
static const int CPU_FEATURE_BIT_POPCNT = 1 << 23;
static const int CPU_FEATURE_BIT_XSAVE = 1 << 26;
static const int CPU_FEATURE_BIT_OXSAVE = 1 << 27;
static const int CPU_FEATURE_BIT_AVX = 1 << 28;
static const int CPU_FEATURE_BIT_F16C = 1 << 29;
static const int CPU_FEATURE_BIT_RDRAND = 1 << 30;
/* cpuid[eax=1].edx */
static const int CPU_FEATURE_BIT_SSE = 1 << 25;
static const int CPU_FEATURE_BIT_SSE2 = 1 << 26;
/* cpuid[eax=0x80000001].ecx */
static const int CPU_FEATURE_BIT_LZCNT = 1 << 5;
/* cpuid[eax=7,ecx=0].ebx */
static const int CPU_FEATURE_BIT_BMI1 = 1 << 3;
static const int CPU_FEATURE_BIT_AVX2 = 1 << 5;
static const int CPU_FEATURE_BIT_BMI2 = 1 << 8;
#if defined(__i386__) && defined(__PIC__)
void __cpuid(int out[4], int op)
{
asm volatile ("xchg{l}\t{%%}ebx, %1\n\t"
"cpuid\n\t"
"xchg{l}\t{%%}ebx, %1\n\t"
: "=a"(out[0]), "=r"(out[1]), "=c"(out[2]), "=d"(out[3])
: "0"(op));
}
void __cpuid_count(int out[4], int op1, int op2)
{
asm volatile ("xchg{l}\t{%%}ebx, %1\n\t"
"cpuid\n\t"
"xchg{l}\t{%%}ebx, %1\n\t"
: "=a" (out[0]), "=r" (out[1]), "=c" (out[2]), "=d" (out[3])
: "0" (op1), "2" (op2));
}
#else
void __cpuid(int out[4], int op)
{
asm volatile("cpuid" : "=a"(out[0]), "=b"(out[1]), "=c"(out[2]), "=d"(out[3])
: "a"(op));
}
void __cpuid_count(int out[4], int op1, int op2)
{
asm volatile("cpuid" : "=a"(out[0]), "=b"(out[1]), "=c"(out[2]), "=d"(out[3])
: "a"(op1), "c"(op2));
}
#endif
int check_xcr0_ymm()
{
int xcr0 = 0;
#if defined(__WIN32__)
#if defined(__INTEL_COMPILER)
xcr0 = (int)_xgetbv(0);
#elif (defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219)) // min VS2010 SP1 compiler is required
xcr0 = (int)_xgetbv(0);
#else
//#pragma message("WARNING: AVX not supported by your compiler.");
xcr0 = 0;
#endif
#else
#if defined(__INTEL_COMPILER)
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx");
#elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && (!defined(__MACOSX__) || defined(__TARGET_AVX__) || defined(__TARGET_AVX2__))
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx");
#elif ((__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ >= 1))
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx");
#else
//#pragma message("WARNING: AVX not supported by your compiler.")
xcr0 = 0;
#endif
#endif
return ((xcr0 & 6) == 6); /* checking if xmm and ymm state are enabled in XCR0 */
}
int get_cpu_features()
{
int info[4] = { 0 };
__cpuid(info, 0x00000000);
unsigned nIds = info[0];
__cpuid(info, 0x80000000);
unsigned nExIds = info[0];
int info1[4] = { 0 };
int info7[4] = { 0 };
int infoe1[4] = { 0 };
if (nIds >= 1) __cpuid(info1, 0x00000001);
#if WIN32
#if _MSC_VER && (_MSC_FULL_VER < 160040219)
if (nIds >= 7) __cpuidex(info7, 0x00000007, 0);
#endif
#else
if (nIds >= 7) __cpuid_count(info7, 0x00000007, 0);
#endif
if (nExIds >= 0x80000001) __cpuid(infoe1, 0x80000001);
int has_ymm = 0;
if (info1[2] & CPU_FEATURE_BIT_OXSAVE)
has_ymm = check_xcr0_ymm();
int cpu_features = 0;
if (info1[3] & CPU_FEATURE_BIT_SSE) cpu_features |= CPU_FEATURE_SSE;
if (info1[3] & CPU_FEATURE_BIT_SSE2) cpu_features |= CPU_FEATURE_SSE2;
if (info1[2] & CPU_FEATURE_BIT_SSE3) cpu_features |= CPU_FEATURE_SSE3;
if (info1[2] & CPU_FEATURE_BIT_SSSE3) cpu_features |= CPU_FEATURE_SSSE3;
if (info1[2] & CPU_FEATURE_BIT_SSE4_1) cpu_features |= CPU_FEATURE_SSE41;
if (info1[2] & CPU_FEATURE_BIT_SSE4_2) cpu_features |= CPU_FEATURE_SSE42;
if (info1[2] & CPU_FEATURE_BIT_POPCNT) cpu_features |= CPU_FEATURE_POPCNT;
if (has_ymm && (info1[2] & CPU_FEATURE_BIT_AVX)) cpu_features |= CPU_FEATURE_AVX;
if (info1[2] & CPU_FEATURE_BIT_F16C) cpu_features |= CPU_FEATURE_F16C;
if (info1[2] & CPU_FEATURE_BIT_RDRAND) cpu_features |= CPU_FEATURE_RDRAND;
if (has_ymm && (info7[1] & CPU_FEATURE_BIT_AVX2)) cpu_features |= CPU_FEATURE_AVX2;
if (has_ymm && (info1[2] & CPU_FEATURE_BIT_FMA3)) cpu_features |= CPU_FEATURE_FMA3;
if (infoe1[2] & CPU_FEATURE_BIT_LZCNT) cpu_features |= CPU_FEATURE_LZCNT;
if (info7[1] & CPU_FEATURE_BIT_BMI1) cpu_features |= CPU_FEATURE_BMI1;
if (info7[1] & CPU_FEATURE_BIT_BMI2) cpu_features |= CPU_FEATURE_BMI2;
#if defined(__MIC__)
cpu_features |= CPU_FEATURE_KNC;
#endif
return cpu_features;
}
int avx_support_level()
{
int cpu_features = get_cpu_features();
if (cpu_features & CPU_FEATURE_AVX2)
return 2;
if (cpu_features & CPU_FEATURE_AVX)
return 1;
return 0;
}
const char *determine_mesa_version()
{
switch (avx_support_level())
{
case 2: return "mesa-swr-avx2";
case 1: return "mesa-swr-avx";
}
return "mesa-llvm";
}
int get_driver_cache_user_path(char *driver_cache_path)
{
const char *home = getenv("HOME");
if (!home)
{
home = getpwuid(getuid())->pw_dir;
}
if (!home)
{
return 0;
}
strncpy(driver_cache_path, home, strlen(home) + 1);
strcat(driver_cache_path, "/.config/ParaView/ParaViewMesaConfig.ini");
//fprintf(stdout, "User cache = %s\n", driver_cache_path);
return 1;
}
int get_driver_cache_site_path(const char *this_exe_path,
char *driver_cache_path)
{
// Get directory containing true paraview executable.
char self_path[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
char throwaway_ldpath[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
char exe[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
kwsys_shared_forward_self_path(this_exe_path, self_path);
kwsys_shared_forward_get_settings(self_path, throwaway_ldpath, exe);
char driver_install_path[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
char *last_slash = strrchr(exe, '/');
if (last_slash)
{
strncpy(driver_install_path, exe, last_slash - exe + 1);
strcat(driver_cache_path, driver_install_path);
strcat(driver_cache_path, "ParaViewMesaConfig.ini");
//fprintf(stdout, "Site cache = %s\n", driver_cache_path);
return 1;
}
return 0;
}
int append_driver_to_ldpath(const char *this_exe_path, const char *driver)
{
char self_path[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
char throwaway_ldpath[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
char exe[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
// Use default native driver, so don't update LD_LIBRARY_PATH
if (!driver || (driver && driver[0] == '\0'))
{
return 0;
}
kwsys_shared_forward_self_path(this_exe_path, self_path);
kwsys_shared_forward_get_settings(self_path, throwaway_ldpath, exe);
char driver_install_path[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
char *last_slash = strrchr(exe, '/');
if (last_slash)
{
strncpy(driver_install_path, exe, last_slash - exe + 1);
strcat(kwsys_shared_forward_ldpath, driver_install_path);
strcat(kwsys_shared_forward_ldpath, driver);
strcat(kwsys_shared_forward_ldpath, kwsys_shared_forward_path_sep);
// Checks
//fprintf(stdout, "driver_install_path = %s\n", driver_install_path);
//fprintf(stdout, "kwsys_shared_forward_ldpath = %s\n",
// kwsys_shared_forward_ldpath);
return 1;
}
return 0;
}
#define MAX_DRIVER_CHOICE 32
int main(int argc, char** argv)
{
int i = 0;
int true_argc = 0;
int true_i = 0;
char **true_argv = malloc((argc + 1) * sizeof(char*));
int result = 0;
FILE *driver_cache = NULL;
char driver_choice[MAX_DRIVER_CHOICE] = { 0 };
char driver_cache_path[KWSYS_SHARED_FORWARD_MAXPATH] = { 0 };
true_argv[argc] = NULL;
// Check for site-wide config first
get_driver_cache_site_path(argv[0], driver_cache_path);
driver_cache = fopen(driver_cache_path, "r");
if (driver_cache)
{
(void)fgets(driver_choice, sizeof(driver_choice), driver_cache);
fclose(driver_cache);
}
// If there is a user config, override the site config
get_driver_cache_user_path(driver_cache_path);
driver_cache = fopen(driver_cache_path, "r");
if (driver_cache)
{
(void)fgets(driver_choice, sizeof(driver_choice), driver_cache);
fclose(driver_cache);
}
// Check for a newline in the driver name
char *newline = strchr(driver_choice, '\n');
if (newline)
{
*newline = '\0';
}
// If config contains "mesa", determine which mesa to use.
if (strlen(driver_choice) && !strcmp(driver_choice, "mesa"))
{
strncpy(driver_choice, determine_mesa_version(), MAX_DRIVER_CHOICE);
}
// Check for single-run driver specification; forward all other args
for (; i < argc; ++i)
{
if (strcmp(argv[i], "--native") == 0)
{
driver_choice[0] = '\0';
}
else if (strcmp(argv[i], "--mesa") == 0)
{
strncpy(driver_choice, determine_mesa_version(), MAX_DRIVER_CHOICE);
}
else if (strcmp(argv[i], "--mesa-llvm") == 0 ||
strcmp(argv[i], "--mesa-swr-avx") == 0 ||
strcmp(argv[i], "--mesa-swr-avx2") == 0)
{
strncpy(driver_choice, argv[i] + 2, MAX_DRIVER_CHOICE);
}
else
{
true_argc++;
true_argv[true_i++] = argv[i];
}
}
// Update the LD_LIBRARY_PATH
append_driver_to_ldpath(argv[0], driver_choice);
// Only read the config file
#if 0
//int driver_changed = 0;
// Update the cache if we changed driver
if (driver_changed)
{
driver_cache = fopen(driver_cache_path, "w");
if (driver_cache)
{
fprintf(driver_cache, "%s", driver_choice);
fclose(driver_cache);
}
else
{
fprintf(stderr, "%s", "Could not write driver cache.\n"
"Run again with super user permissions.\n");
}
}
#endif
// Check original args vs. forwarded args
#if 0
// Original
printf("%d original args:\n", argc);
for (i = 0; i < argc; ++i)
{
printf("\t%s\n", argv[i]);
}
// Forwarded
printf("%d forwarded args:\n", true_argc);
for (i = 0; i < true_argc; ++i)
{
printf("\t%s\n", true_argv[i]);
}
#endif
result = vtksys_shared_forward_to_real(true_argc, true_argv);
free(true_argv);
return result;
}
--
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
http://lists.fedoraproject.org/admin/lists/devel@xxxxxxxxxxxxxxxxxxxxxxx