cygwin build patch

LLVM doesn't build out of the box on Cygwin, because Cygwin defines
uint32_t as "unsigned long" rather than "unsigned int".

The attached patch allows me to build head of svn (rev 62510) on
Cygwin using GCC 4. Can this be committed please?

I realise that the DataTypes.h.in part might be controversial. Also,
there's probably a better place to put it, but I'm not sure where.

Thanks,
Jay.

cygwin.patch (2.87 KB)

LLVM doesn't build out of the box on Cygwin, because Cygwin defines
uint32_t as "unsigned long" rather than "unsigned int".

The attached patch allows me to build head of svn (rev 62510) on
Cygwin using GCC 4. Can this be committed please?

Thanks applied:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090119/072367.html

I realise that the DataTypes.h.in part might be controversial. Also,
there's probably a better place to put it, but I'm not sure where.

I didn't apply this part. What problems does it cause to not have this? Can we fix uses of max and min?

-Chris

I realise that the DataTypes.h.in part might be controversial. Also,
there's probably a better place to put it, but I'm not sure where.

I didn't apply this part. What problems does it cause to not have
this? Can we fix uses of max and min?

I get these errors in lib:

.../lib/Analysis/ValueTracking.cpp:162: error: no matching function
for call to 'min(unsigned int&, uint32_t&)'
.../lib/Analysis/ValueTracking.cpp:163: error: no matching function
for call to 'min(unsigned int&, uint32_t&)'
.../lib/Analysis/ValueTracking.cpp:358: error: no matching function
for call to 'min(unsigned int&, uint32_t)'
.../lib/Analysis/ValueTracking.cpp:469: error: no matching function
for call to 'min(unsigned int&, long unsigned int)'
.../lib/Analysis/ValueTracking.cpp:708: error: no matching function
for call to 'min(unsigned int&, uint32_t)'
.../lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1432: error: no matching
function for call to 'max(long unsigned int, unsigned int&)'
.../lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1747: error: no matching
function for call to 'min(unsigned int&, uint32_t)'
.../lib/CodeGen/SelectionDAG/SelectionDAG.cpp:2033: error: no matching
function for call to 'min(unsigned int&, uint32_t)'

I could try to fix this by changing the code to consistently use
either unsigned or uint32_t (which?), rather than both. Or by adding
casts at the point of calling min/max. What would you prefer?

Thanks,
Jay.

I'd prefer to avoid uint32_t. I committed a couple patches, can you try again and let me know if you see any other failures?

-Chris

I'd prefer to avoid uint32_t. I committed a couple patches, can you
try again and let me know if you see any other failures?

lib/Support/APInt.cpp:45: error: prototype for 'void
llvm::APInt::initSlowCase(uint32_t, uint64_t, bool)' does not match
any in class 'llvm::APInt'
lib/Support/APInt.cpp:59: error: prototype for
'llvm::APInt::APInt(uint32_t, uint32_t, const uint64_t*)' does not
match any in class 'llvm::APInt'
lib/Support/APInt.cpp:78: error: prototype for
'llvm::APInt::APInt(uint32_t, const char*, uint32_t, uint8_t)' does
not match any in class 'llvm::APInt'
lib/Support/APInt.cpp:458: error: prototype for 'bool
llvm::APInt::operator(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:559: error: prototype for 'llvm::APInt&
llvm::APInt::set(uint32_t)' does not match any in class 'llvm::APInt'
lib/Support/APInt.cpp:569: error: prototype for 'llvm::APInt&
llvm::APInt::clear(uint32_t)' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:582: error: prototype for 'llvm::APInt&
llvm::APInt::flip(uint32_t)' does not match any in class 'llvm::APInt'
lib/Support/APInt.cpp:589: error: prototype for 'uint32_t
llvm::APInt::getBitsNeeded(const char*, uint32_t, uint8_t)' does not
match any in class 'llvm::APInt'
lib/Support/APInt.cpp:640: error: prototype for 'llvm::APInt
llvm::APInt::getHiBits(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:645: error: prototype for 'llvm::APInt
llvm::APInt::getLoBits(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:654: error: prototype for 'uint32_t
llvm::APInt::countLeadingZerosSlowCase() const' does not match any in
class 'llvm::APInt'
lib/Support/APInt.cpp:681: error: prototype for 'uint32_t
llvm::APInt::countLeadingOnes() const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:702: error: prototype for 'uint32_t
llvm::APInt::countTrailingZeros() const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:714: error: prototype for 'uint32_t
llvm::APInt::countTrailingOnesSlowCase() const' does not match any in
class 'llvm::APInt'
lib/Support/APInt.cpp:724: error: prototype for 'uint32_t
llvm::APInt::countPopulationSlowCase() const' does not match any in
class 'llvm::APInt'
lib/Support/APInt.cpp:768: error: 'llvm::APInt
llvm::APIntOps::RoundDoubleToAPInt(double, uint32_t)' should have been
declared inside 'llvm::APIntOps'
lib/Support/APInt.cpp:871: error: prototype for 'llvm::APInt&
llvm::APInt::trunc(uint32_t)' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:894: error: prototype for 'llvm::APInt&
llvm::APInt::sext(uint32_t)' does not match any in class 'llvm::APInt'
lib/Support/APInt.cpp:941: error: prototype for 'llvm::APInt&
llvm::APInt::zext(uint32_t)' does not match any in class 'llvm::APInt'
lib/Support/APInt.cpp:960: error: prototype for 'llvm::APInt&
llvm::APInt::zextOrTrunc(uint32_t)' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:968: error: prototype for 'llvm::APInt&
llvm::APInt::sextOrTrunc(uint32_t)' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:984: error: prototype for 'llvm::APInt
llvm::APInt::ashr(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:1073: error: prototype for 'llvm::APInt
llvm::APInt::lshr(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:1140: error: prototype for 'llvm::APInt
llvm::APInt::shlSlowCase(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:1194: error: prototype for 'llvm::APInt
llvm::APInt::rotl(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:1209: error: prototype for 'llvm::APInt
llvm::APInt::rotr(uint32_t) const' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:1539: error: prototype for 'void
llvm::APInt::divide(llvm::APInt, uint32_t, const llvm::APInt&,
uint32_t, llvm::APInt*, llvm::APInt*)' does not match any in class
'llvm::APInt'
lib/Support/APInt.cpp:1828: error: prototype for 'void
llvm::APInt::fromString(uint32_t, const char*, uint32_t, uint8_t)'
does not match any in class 'llvm::APInt'
lib/Support/APInt.cpp:670: warning: 'uint32_t
countLeadingOnes_64(uint64_t, uint32_t)' defined but not used
lib/Support/APInt.cpp:1359: warning: 'void KnuthDiv(uint32_t*,
uint32_t*, uint32_t*, uint32_t*, uint32_t, uint32_t)' defined but not
used

:frowning:

I can have a go at fixing this - it's probably gonna be hard to do it blind.

Thanks,
Jay.

I'd prefer to avoid uint32_t. I committed a couple patches, can you
try again and let me know if you see any other failures?

With the attached patch I can build successfully on Cygwin.

The APInt.cpp part of the patch is just s/uint32_t/unsigned/g.

Thanks,
Jay.

cygwin.patch (40.5 KB)

Using an explicit instantiation, e.g. std::min<uint32_t>(), is sometimes a good fix and more succinct than an casting one of the arguments.

Thanks Jay! You beat me to it :), applied here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090119/072479.html

-chris

Thanks Jay! You beat me to it :), applied here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090119/072479.html

Thanks. Just to confirm, I can now build head of svn (rev 62762)
cleanly on Cygwin with GCC 4.

With GCC 3.4.4 (Cygwin's default) I still have this problem:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-January/019563.html

Thanks,
Jay.