Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for clang compiler #592

Merged
merged 28 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cc56a5a
hacks to align strings for clang... wow just wow
crowell Jul 4, 2022
6879520
start work to getting built with clang
crowell Jun 20, 2022
1e10fbc
fix issues with struct constructors, all builds, doesn't link still
crowell Jun 20, 2022
0edb646
fix some narrowing issues that clang complains about
crowell Jun 20, 2022
dadd0c7
fix compliation of zapd
crowell Jun 20, 2022
4febaa3
fix null deref in VersionInfo
crowell Jun 20, 2022
56718c4
builds with clang
crowell Jun 20, 2022
bce7ecf
make stringbuilding use StringHelper instead of addition
crowell Jul 5, 2022
54d3c3b
fix linking
crowell Jul 5, 2022
098cb8c
add CLANG SHIP overlay on clang built versions
crowell Jun 29, 2022
211bf79
doesn't need to be volatile
crowell Jul 5, 2022
ffabc6b
mark unknown strings as extern
crowell Jul 5, 2022
e8371b0
rename some stuff
crowell Jul 5, 2022
aaf1632
can't align extern
crowell Jul 5, 2022
2b29dbb
hopefully fix compilation for everythign
crowell Jul 8, 2022
205f815
expandtab
crowell Jul 8, 2022
711aba6
allow setting LD
crowell Jul 8, 2022
b2a663f
Revert "allow setting LD"
crowell Jul 8, 2022
388bf40
-Wno-deprecated-declarations is required for newer versions of clang
crowell Jul 8, 2022
94f9818
Add jenkins support for clang
dcvz Jul 8, 2022
39c67da
Forward CXX flags to stormlib compilation
dcvz Jul 8, 2022
6faedf8
Merge branch 'develop' into devel-clang
crowell Jul 8, 2022
563cd97
Move GCC only flags to check
dcvz Jul 8, 2022
439b319
use exports to set multiarch setup
dcvz Jul 8, 2022
4453b38
Fix Jenkins forever
dcvz Jul 8, 2022
b594621
use make instead of cmake --build
crowell Jul 9, 2022
de879d2
address review coments
crowell Jul 9, 2022
e670d74
update makefile to add WARN on linux+clang
crowell Jul 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ make -j $(nproc) OPTFLAGS=-O2 DEBUG=0

## macOS

1. Requires `gcc@12, sdl2, libpng, glew, dylibbundler` (can be installed via brew, etc)
1. Requires Xcode (or xcode-tools) && `sdl2, libpng, glew, dylibbundler` (can be installed via brew, etc)
```bash
# Clone the repo
git clone https://github.com/HarbourMasters/Shipwright.git
Expand All @@ -59,9 +59,9 @@ cp <path to your ROM> OTRExporter
cd soh
# Extract the assets/Compile the exporter/Run the exporter
# -jX defines number of cores to use for compilation - lower or remove entirely if having issues
make setup -j8 DEBUG=0 CC=gcc-12 CXX=g++-12
make setup -j8 DEBUG=0
# Compile the code (watch the -j parameter as above)
make -j8 DEBUG=0 CC=gcc-12 CXX=g++-12
make -j8 DEBUG=0
# Create macOS app bundle
make filledappbundle
```
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ pipeline {
sh '''
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
cd soh
make setup -j4 DEBUG=0 OPTFLAGS=-O2 CC=gcc-12 CXX=g++-12
make -j4 DEBUG=0 OPTFLAGS=-O2 CC=gcc-12 CXX=g++-12
export CC="clang -arch arm64 -arch x86_64"; export CXX="clang++ -arch arm64 -arch x86_64"; make setup -j4 OPTFLAGS=-O2 DEBUG=0 LD="ld"
export CC="clang -arch arm64 -arch x86_64"; export CXX="clang++ -arch arm64 -arch x86_64"; make -j4 DEBUG=0 OPTFLAGS=-O2 LD="ld"
make -j4 appbundle
mv ../README.md readme.txt
7z a soh-mac.7z soh.app readme.txt
Expand Down
78 changes: 39 additions & 39 deletions OTRExporter/OTRExporter/DisplayListExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
{
case G_NOOP:
{
Gfx value = gsDPNoOp();
Gfx value = {gsDPNoOp()};
word0 = value.words.w0;
word1 = value.words.w1;
}
break;
case G_ENDDL:
{
Gfx value = gsSPEndDisplayList();
Gfx value = {gsSPEndDisplayList()};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -114,7 +114,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t nnnn = (data & 0x0000FFFF00000000ULL) >> 32;
int32_t vvvvvvvv = (data & 0x00000000FFFFFFFFULL);

Gfx value = gsSPModifyVertex(nnnn / 2, ww, vvvvvvvv);
Gfx value = {gsSPModifyVertex(nnnn / 2, ww, vvvvvvvv)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -131,35 +131,35 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t cccccc = (data & 0x00FFFFFF00000000) >> 32;
int32_t ssssssss = (data & 0xFFFFFFFF);

Gfx value = gsSPGeometryMode(~cccccc, ssssssss);
Gfx value = {gsSPGeometryMode(~cccccc, ssssssss)};
word0 = value.words.w0;
word1 = value.words.w1;
}
break;
case G_RDPPIPESYNC:
{
Gfx value = gsDPPipeSync();
Gfx value = {gsDPPipeSync()};
word0 = value.words.w0;
word1 = value.words.w1;
}
break;
case G_RDPLOADSYNC:
{
Gfx value = gsDPLoadSync();
Gfx value = {gsDPLoadSync()};
word0 = value.words.w0;
word1 = value.words.w1;
}
break;
case G_RDPTILESYNC:
{
Gfx value = gsDPTileSync();
Gfx value = {gsDPTileSync()};
word0 = value.words.w0;
word1 = value.words.w1;
}
break;
case G_RDPFULLSYNC:
{
Gfx value = gsDPFullSync();
Gfx value = {gsDPFullSync()};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -169,14 +169,14 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t hhhhhh = (data & 0x00FFFFFF00000000) >> 32;
int32_t llllllll = (data & 0x00000000FFFFFFFF);

Gfx value = gsDPSetOtherMode(hhhhhh, llllllll);
Gfx value = {gsDPSetOtherMode(hhhhhh, llllllll)};
word0 = value.words.w0;
word1 = value.words.w1;
}
break;
case G_POPMTX:
{
Gfx value = gsSPPopMatrix(data);
Gfx value = {gsSPPopMatrix(data)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -188,7 +188,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
uint8_t b = (uint8_t)((data & 0xFF00FF00) >> 8);
uint8_t a = (uint8_t)((data & 0x000000FF) >> 0);

Gfx value = gsDPSetEnvColor(r, g, b, a);
Gfx value = {gsDPSetEnvColor(r, g, b, a)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -204,7 +204,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina

mm = (mm & 0x0FFFFFFF) + 1;

Gfx value = gsSPMatrix(mm, pp);
Gfx value = {gsSPMatrix(mm, pp)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -214,7 +214,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
uint32_t mm = (data & 0x00000000FFFFFFFF);
pp ^= G_MTX_PUSH;

Gfx value = gsSPMatrix(mm, pp);
Gfx value = {gsSPMatrix(mm, pp)};
word0 = value.words.w0;
word1 = value.words.w1;

Expand Down Expand Up @@ -253,7 +253,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t xxx = (data & 0x0000000000FFF000) >> 12;
int32_t ddd = (data & 0x0000000000000FFF);

Gfx value = gsDPLoadBlock(i, sss, ttt, xxx, ddd);
Gfx value = {gsDPLoadBlock(i, sss, ttt, xxx, ddd)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -263,7 +263,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t vvvv = (data & 0xFFFF00000000) >> 32;
int32_t wwww = (data & 0x0000FFFF);

Gfx value = gsSPCullDisplayList(vvvv / 2, wwww / 2);
Gfx value = {gsSPCullDisplayList(vvvv / 2, wwww / 2)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -279,7 +279,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
uint32_t z = (data & 0x00000000FFFFFFFF) >> 0;
uint32_t h = (data & 0xFFFFFFFF);

Gfx value = gsSPBranchLessZraw3(h & 0x00FFFFFF);
Gfx value = {gsSPBranchLessZraw3(h & 0x00FFFFFF)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -292,7 +292,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
break;
case G_RDPHALF_2:
{
Gfx value = gsDPWordLo(data & 0xFFFFFFFF);
Gfx value = {gsDPWordLo(data & 0xFFFFFFFF)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -305,7 +305,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t XXX = (data & 0x0000000000FFF000) >> 12;
int32_t YYY = (data & 0x0000000000000FFF);

Gfx value = gsSPTextureRectangle2(XXX, YYY, xxx, yyy, i);
Gfx value = {gsSPTextureRectangle2(XXX, YYY, xxx, yyy, i)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -324,7 +324,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina

int bp = 0;

Gfx value = gsSPBranchLessZraw2(0xDEADABCD, (a / 5) | (b / 2), z);
Gfx value = {gsSPBranchLessZraw2(0xDEADABCD, (a / 5) | (b / 2), z)};
word0 = (value.words.w0 & 0x00FFFFFF) + (G_BRANCH_Z_OTR << 24);
word1 = value.words.w1;

Expand Down Expand Up @@ -389,9 +389,9 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
u32 dListVal = (data & 0x0FFFFFFF) + 1;

if (pp != 0)
value = gsSPBranchList(dListVal);
value = {gsSPBranchList(dListVal)};
else
value = gsSPDisplayList(dListVal);
value = {gsSPDisplayList(dListVal)};

word0 = value.words.w0;
word1 = value.words.w1;
Expand Down Expand Up @@ -469,7 +469,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t ddd = (____ & 0x700) >> 8;
int32_t nnnnnnn = (____ & 0xFE) >> 1;

Gfx value = gsSPTexture(ssss, tttt, lll, ddd, nnnnnnn);
Gfx value = {gsSPTexture(ssss, tttt, lll, ddd, nnnnnnn)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -480,7 +480,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2;
int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2;

Gfx test = gsSP1Triangle(aa, bb, cc, 0);
Gfx test = {gsSP1Triangle(aa, bb, cc, 0)};
word0 = test.words.w0;
word1 = test.words.w1;
}
Expand All @@ -494,7 +494,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t ee = ((data & 0x0000000000FF00ULL) >> 8) / 2;
int32_t ff = ((data & 0x000000000000FFULL) >> 0) / 2;

Gfx test = gsSP2Triangles(aa, bb, cc, 0, dd, ee, ff, 0);
Gfx test = {gsSP2Triangles(aa, bb, cc, 0, dd, ee, ff, 0)};
word0 = test.words.w0;
word1 = test.words.w1;
}
Expand All @@ -506,7 +506,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2;
int32_t dd = ((data & 0x000000000000FFULL)) / 2;

Gfx test = gsSP1Quadrangle(aa, bb, cc, dd, 0);
Gfx test = {gsSP1Quadrangle(aa, bb, cc, dd, 0)};
word0 = test.words.w0;
word1 = test.words.w1;
}
Expand All @@ -520,7 +520,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t bb = (data & 0x000000000000FF00) >> 8;
int32_t aa = (data & 0x00000000000000FF) >> 0;

Gfx value = gsDPSetPrimColor(mm, ff, rr, gg, bb, aa);
Gfx value = {gsDPSetPrimColor(mm, ff, rr, gg, bb, aa)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -534,7 +534,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina

// TODO: Output the correct render modes in data

Gfx value = gsSPSetOtherMode(0xE2, sft, len, dd);
Gfx value = {gsSPSetOtherMode(0xE2, sft, len, dd)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -552,11 +552,11 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
if (sft == 14) // G_MDSFT_TEXTLUT
{
const char* types[] = { "G_TT_NONE", "G_TT_NONE", "G_TT_RGBA16", "G_TT_IA16" };
value = gsDPSetTextureLUT(dd >> 14);
value = {gsDPSetTextureLUT(dd >> 14)};
}
else
{
value = gsSPSetOtherMode(0xE3, sft, nn + 1, dd);
value = {gsSPSetOtherMode(0xE3, sft, nn + 1, dd)};
}

word0 = value.words.w0;
Expand All @@ -583,7 +583,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t bbbb = (data & 0b0000000000000000000000000000000000000000000000000000000011110000) >> 4;
int32_t uuuu = (data & 0b0000000000000000000000000000000000000000000000000000000000001111);

Gfx value = gsDPSetTile(fff, ii, nnnnnnnnn, mmmmmmmmm, ttt, pppp, cc, aaaa, ssss, dd, bbbb, uuuu);
Gfx value = {gsDPSetTile(fff, ii, nnnnnnnnn, mmmmmmmmm, ttt, pppp, cc, aaaa, ssss, dd, bbbb, uuuu)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -607,7 +607,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t ab1 = (data & 0b00000000000000000000000000000000000000000000000000000000111000) >> 3;
int32_t ad1 = (data & 0b00000000000000000000000000000000000000000000000000000000000111) >> 0;

Gfx value = gsDPSetCombineLERP2(a0, b0, c0, d0, aa0, ab0, ac0, ad0, a1, b1, c1, d1, aa1, ab1, ac1, ad1);
Gfx value = {gsDPSetCombineLERP2(a0, b0, c0, d0, aa0, ab0, ac0, ad0, a1, b1, c1, d1, aa1, ab1, ac1, ad1)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -620,7 +620,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t vvv = (data & 0x0000000000000FFF);
int32_t i = (data & 0x000000000F000000) >> 24;

Gfx value = gsDPSetTileSize(i, sss, ttt, uuu, vvv);
Gfx value = {gsDPSetTileSize(i, sss, ttt, uuu, vvv)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -630,7 +630,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t t = (data & 0x0000000007000000) >> 24;
int32_t ccc = (data & 0x00000000003FF000) >> 14;

Gfx value = gsDPLoadTLUTCmd(t, ccc);
Gfx value = {gsDPLoadTLUTCmd(t, ccc)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -643,7 +643,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int uuu = (data & 0x0000000000FFF000) >> 12;
int vvv= (data & 0x0000000000000FFF);

Gfx value = gsDPLoadTile(i, sss, ttt, uuu, vvv);
Gfx value = {gsDPLoadTile(i, sss, ttt, uuu, vvv)};
word0 = value.words.w0;
word1 = value.words.w1;
}
Expand All @@ -661,7 +661,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
uint32_t fmt = (__ & 0xE0) >> 5;
uint32_t siz = (__ & 0x18) >> 3;

Gfx value = gsDPSetTextureImage(fmt, siz, www + 1, (seg & 0x0FFFFFFF) + 1);
Gfx value = {gsDPSetTextureImage(fmt, siz, www + 1, (seg & 0x0FFFFFFF) + 1)};
word0 = value.words.w0;
word1 = value.words.w1;

Expand All @@ -679,7 +679,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
uint32_t fmt = (__ & 0xE0) >> 5;
uint32_t siz = (__ & 0x18) >> 3;

Gfx value = gsDPSetTextureImage(fmt, siz, www + 1, __);
Gfx value = {gsDPSetTextureImage(fmt, siz, www + 1, __)};
word0 = value.words.w0 & 0x00FFFFFF;
word0 += (G_SETTIMG_OTR << 24);
//word1 = value.words.w1;
Expand Down Expand Up @@ -722,7 +722,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
int32_t aa = (data & 0x000000FF00000000ULL) >> 32;
int32_t nn = (data & 0x000FF00000000000ULL) >> 44;

Gfx value = gsSPVertex(data & 0xFFFFFFFF, nn, ((aa >> 1) - nn));
Gfx value = {gsSPVertex(data & 0xFFFFFFFF, nn, ((aa >> 1) - nn))};

word0 = value.words.w0;
word1 = value.words.w1 | 1;
Expand All @@ -745,7 +745,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
{
uint32_t diff = segOffset - vtxDecl->address;

Gfx value = gsSPVertex(diff, nn, ((aa >> 1) - nn));
Gfx value = {gsSPVertex(diff, nn, ((aa >> 1) - nn))};

word0 = value.words.w0;
word0 &= 0x00FFFFFF;
Expand Down Expand Up @@ -893,4 +893,4 @@ std::string OTRExporter_DisplayList::GetPrefix(ZResource* res)
prefix = "code";

return prefix;
}
}
4 changes: 2 additions & 2 deletions OTRExporter/OTRExporter/VersionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ std::map<Ship::ResourceType, uint32_t> resourceVersions;

void InitVersionInfo()
{
resourceVersions = {
resourceVersions = std::map<Ship::ResourceType, uint32_t> {
{ Ship::ResourceType::Animation, 0 },
{ Ship::ResourceType::Model, 0 },
{ Ship::ResourceType::Texture, 0 },
Expand All @@ -24,4 +24,4 @@ void InitVersionInfo()
{ Ship::ResourceType::Text, 0 },
{ Ship::ResourceType::Blob, 0 },
};
}
}
2 changes: 1 addition & 1 deletion ZAPDTR/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ lib/libgfxd/libgfxd.a:
.PHONY: StormLib
StormLib:
LDFLAGS="" cmake -B ../StormLib/build -S ../StormLib
LDFLAGS="" cmake --build ../StormLib/build
$(MAKE) -C ../StormLib/build

.PHONY: ExporterTest
ExporterTest:
Expand Down
Loading