Issue 1:
🐛 Bug

I'm trying to build PyTorch 1.2.0 from source. The CMake phase passes successfully, but building fails.

To Reproduce

Steps to reproduce the behavior:

$ python setup.py build
In file included from nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/typeid.h:24:0^[[K,
from nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/core/DefaultDtype.cpp:1^[[K:
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:^[[K':
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:106:56:^[[K' was not declared in this scope
const uint32_t sign = w & UINT32_C(0x80000000);
^[[K
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:138:72:^[[K' was not declared in this scope
((int32_t)(nonsign + 0x04000000) >> 8) & INT32_C(0x7F800000);
^[[K
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:^[[K':
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:197:56:^[[K' was not declared in this scope
const uint32_t sign = w & UINT32_C(0x80000000);
^[[K
In file included from nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/typeid.h:24:0^[[K,
from nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/core/DefaultDtype.cpp:1^[[K:
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:_fp32_value(float)^[[K':
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:308:56:^[[K' was not declared in this scope
const uint32_t sign = w & UINT32_C(0x80000000);
^[[K
nt/c/scratch/sciteam/stewart1/spack-stage/spack-stage-faGxK3/spack-src/c10/util/Half.h:319:81:^[[K' was not declared in this scope
return (sign >> 16) | (shl1_w > UINT32_C(0xFF000000) ? UINT16_C(0x7E00) : nonsign);
^[[K
[ 4%] Generating python/data_parallel_model.py
gmake[2]: *** [c10/CMakeFiles/c10.dir/core/DefaultDtype.cpp.o] Error 1
gmake[1]: *** [c10/CMakeFiles/c10.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....

Expected behavior

Should build fine.

Environment

PyTorch Version (e.g., 1.0): 1.2.0

OS (e.g., Linux): Cray CNL5

How you installed PyTorch (conda, pip, source): source

Build command you used (if compiling from source): python setup.py build

Python version: 3.7.4

CUDA/cuDNN version: 9.1.85

Issue 2:
🐛 Bug

To Reproduce

Steps to reproduce the behavior:

git clone the pytorch repo and all the submodules

Build pytorch with:

export CMAKE_PREFIX_PATH=$LINUXBREWHOME:$LINUXBREWHOME/Cellar/cuda/10.1
export CUDA_HOME=$LINUXBREWHOME/Cellar/cuda/10.1
export BLAS=OpenBLAS
export MAX_JOBS=16
export USE_CUDA=1
export USE_CUDNN=1
export USE_NUMPY=1
export TORCH_CUDA_ARCH_LIST="6.1;7.5"
export LIBRARY_PATH=$LINUXBREWHOME/lib:$LINUXBREWHOME/Cellar/cuda/10.1/lib
export CC=$LINUXBREWHOME/bin/gcc-5
export CXX=$LINUXBREWHOME/bin/g++-5
python3 setup.py clean
python3 setup.py bdist_wheel

where I have all my compiler toolchain in $LINUXBREWHOME

3. I got this error:

/home/aznb/.linuxbrew/bin/g++-5 -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DONNX_NAMESPACE=onnx_torch -DUSE_GCC_ATOMICS=1 -D_FILE_OFFSET_BITS=64 -Dc10_EXPORTS -I../aten/src -I. -I../ -I../third_party/protobuf/src -I../cmake/../third_party/benchmark/include -Icaffe2/contrib/aten -I../third_party/onnx -Ithird_party/onnx -I../third_party/foxi -Ithird_party/foxi -I../c10/.. -isystem third_party/gloo -isystem ../cmake/../third_party/gloo -isystem ../cmake/../third_party/googletest/googlemock/include -isystem ../cmake/../third_party/googletest/googletest/include -isystem ../third_party/gemmlowp -isystem ../third_party/neon2sse -isystem ../third_party -isystem /usr/include -isystem ../cmake/../third_party/eigen -isystem /home/aznb/.linuxbrew/Cellar/python/3.7.4/include/python3.7m -isystem /home/aznb/.linuxbrew/Cellar/python/3.7.4/lib/python3.7/site-packages/numpy/core/include -isystem ../cmake/../third_party/pybind11/include -isystem /home/aznb/.linuxbrew/Cellar/open-mpi/4.0.1_1/include -isystem ../third_party/ideep/mkl-dnn/include -isystem ../third_party/ideep/include -isystem ../third_party/ideep/mkl-dnn/external/mklml_lnx_2019.0.3.20190220/include -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -O3 -fPIC -DCAFFE2_USE_GLOO -DCUDA_HAS_FP16=1 -DHAVE_GCC_GET_CPUID -DUSE_AVX -DUSE_AVX2 -DTH_HAVE_THREAD -DC10_BUILD_MAIN_LIB -fvisibility=hidden -std=gnu++11 -MD -MT c10/CMakeFiles/c10.dir/core/CPUAllocator.cpp.o -MF c10/CMakeFiles/c10.dir/core/CPUAllocator.cpp.o.d -o c10/CMakeFiles/c10.dir/core/CPUAllocator.cpp.o -c ../c10/core/CPUAllocator.cpp
In file included from ../c10/util/typeid.h:24:0,
from ../c10/core/CPUAllocator.cpp:2:
../c10/util/Half.h: In function 'uint32_t c10::detail::fp16_ieee_to_fp32_bits(uint16_t)':
../c10/util/Half.h:107:56: error: 'UINT32_C' was not declared in this scope
const uint32_t sign = w & UINT32_C(0x80000000);
^
../c10/util/Half.h:139:72: error: 'INT32_C' was not declared in this scope
((int32_t)(nonsign + 0x04000000) >> 8) & INT32_C(0x7F800000);
^
../c10/util/Half.h: In function 'float c10::detail::fp16_ieee_to_fp32_value(uint16_t)':
../c10/util/Half.h:198:56: error: 'UINT32_C' was not declared in this scope
const uint32_t sign = w & UINT32_C(0x80000000);

Expected behavior

pytorch build successfully

Environment

PyTorch Version (e.g., 1.0): 1.1.0

OS (e.g., Linux): centos 6.9

How you installed PyTorch (conda, pip, source): source

Build command you used (if compiling from source): see above

Python version: 3.7.4

CUDA/cuDNN version: 10.1/7.6.2

GPU models and configuration: GTX 1080

Any other relevant information:

Additional context

gcc has it's definition for INT32_C in stdint-gcc.h. If I add #include <stdint-gcc.h> to c10/util/Half.h then it compiles fine