From d24fe57586049bbc1bfd35676f84cc6e5ae8a26f Mon Sep 17 00:00:00 2001
From: bsardo <1168933+bsardo@users.noreply.github.com>
Date: Wed, 18 Sep 2024 11:38:40 -0400
Subject: [PATCH 1/6] Add build/run readme
---
run/README.md | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
create mode 100644 run/README.md
diff --git a/run/README.md b/run/README.md
new file mode 100644
index 00000000000..2e7197cea34
--- /dev/null
+++ b/run/README.md
@@ -0,0 +1,100 @@
+## Overview
+
+Prebid Server contains at least one module that requires CGo which introduces both build and runtime dependencies.
+To build, you need a C compiler, preferably gcc.
+To run, you may require one or more runtime dependencies, most notably libatomic.
+
+## Examples (Build --> Target)
+Here are some manual build examples, including some cross-compilation use cases, that have been tested:
+
+### darwin amd64 --> darwin amd64
+`GOOS=darwin GOARCH=amd64 go build`
+
+Running the built binary on mac amd64:
+`./prebid-server --stderrthreshold=WARNING -v=2`
+
+### darwin amd64 --> darwin arm64
+`GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build`
+
+Running the built binary on mac arm64:
+`./prebid-server --stderrthreshold=WARNING -v=2`
+
+### darwin amd64 --> windows amd64
+Build (mac):
+Install mingw-w64 which consists of a gcc compiler port you can use to generate windows binaries:
+`brew install mingw-w64`
+
+From the root of the project:
+`GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" go build`
+
+Run (windows)
+`.\prebid-server.exe --sderrthreshold=WARNING =v=2`
+
+You may see the following errors:
+```
+"The code execution cannot proceed because libatomic-1.dll was not found."
+"The code execution cannot proceed because libwinpthread-1.dll was not found."
+```
+
+To resolve these errors:
+1) Copy the following files from mingw-64 on your mac to `C:/windows/System32`:
+`/usr/local/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/lib/libatomic-1.dll`
+`/usr/local/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/bin/libwinpthread-1.dll`
+2) Register the DLLs on your windows machine using the regsvr32 command:
+`regsvr32 "C:\Windows\System32\libatomic-1.dll"`
+`regsvr32 "C:\Windows\System32\libwinpthread-1.dll"`
+
+`.\prebid-server.exe --sderrthreshold=WARNING =v=2`
+
+### windows amd64 --> windows amd64
+Build
+`set CGO_ENABLED=1`
+`set GOOS=windows`
+`set GOARCH=amd64`
+`go build . && .\prebid-server.exe --stderrthreshold=WARNING -v=2`
+
+If during the build you get an error similar to:
+```
+# runtime/cgo
+cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%
+```
+
+install MSYS2:
+1) download the installer (TODO: link)
+2) run the installer
+3) run MSYS2
+4) install windows/amd64 gcc toolchain: `pacman -S --needed base-devel mingw-w64-x86_64-gcc`
+5) enter `Y` when prompted whether to proceed with the installation
+6) Add the path of your MinGW-w64 bin folder to the Windows PATH environment variable by using the following steps:
+- In the Windows search bar, type Settings to open your Windows Settings.
+- Search for Edit environment variables for your account.
+- In your User variables, select the Path variable and then select Edit.
+- Select New and add the MinGW-w64 destination folder you recorded during the installation process to the list. If you used the default settings above, then this will be the path: C:\msys64\ucrt64\bin.
+- Select OK, and then select OK again in the Environment Variables window to update the PATH environment variable. You have to reopen any console windows for the updated PATH environment variable to be available.
+7) confirm gcc installed: `gcc --version`
+
+Run
+`go build . && .\prebid-server.exe --stderrthreshold=WARNING -v=2`
+
+### linux amd64 --> linux amd64
+Tests
+Debian or Ubuntu Linux targeting a Debian-based Linux distribution
+
+Build
+`GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build`
+
+If during the build you get an error similar to:
+```
+# runtime/cgo
+cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
+```
+install gcc, by running `sudo apt-get install -y gcc`
+
+Run
+Running the built binary on Linux:
+`./prebid-server --stderrthreshold=WARNING -v=2`
+If you get an error:
+```
+... error while loading shared libraries: libatomic.so.1: cannot open shared object file ...
+```
+install libatomic1, by running `sudo apt-get install -y libatomic1`
\ No newline at end of file
From 012abfdd75330fa208b7e0a3585559572cc1a565 Mon Sep 17 00:00:00 2001
From: bsardo <1168933+bsardo@users.noreply.github.com>
Date: Thu, 19 Sep 2024 09:56:27 -0400
Subject: [PATCH 2/6] WIP
---
run/README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/run/README.md b/run/README.md
index 2e7197cea34..601484cdc96 100644
--- a/run/README.md
+++ b/run/README.md
@@ -5,10 +5,11 @@ To build, you need a C compiler, preferably gcc.
To run, you may require one or more runtime dependencies, most notably libatomic.
## Examples (Build --> Target)
+For a containerized example, see the Dockerfile.
Here are some manual build examples, including some cross-compilation use cases, that have been tested:
### darwin amd64 --> darwin amd64
-`GOOS=darwin GOARCH=amd64 go build`
+`GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build`
Running the built binary on mac amd64:
`./prebid-server --stderrthreshold=WARNING -v=2`
From b002b3ab92b244d0ceb8e3ce8b91a882a671cdc9 Mon Sep 17 00:00:00 2001
From: bsardo <1168933+bsardo@users.noreply.github.com>
Date: Thu, 19 Sep 2024 12:49:54 -0400
Subject: [PATCH 3/6] Updates
---
run/README.md | 66 +++++++++++++++++++++++++++------------------------
1 file changed, 35 insertions(+), 31 deletions(-)
diff --git a/run/README.md b/run/README.md
index 601484cdc96..3a5e6690044 100644
--- a/run/README.md
+++ b/run/README.md
@@ -21,31 +21,25 @@ Running the built binary on mac arm64:
`./prebid-server --stderrthreshold=WARNING -v=2`
### darwin amd64 --> windows amd64
-Build (mac):
+Build (mac)
Install mingw-w64 which consists of a gcc compiler port you can use to generate windows binaries:
`brew install mingw-w64`
-From the root of the project:
`GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" go build`
Run (windows)
+Running the built binary on windows:
`.\prebid-server.exe --sderrthreshold=WARNING =v=2`
-You may see the following errors:
+You may receive the following errors or something similar:
```
"The code execution cannot proceed because libatomic-1.dll was not found."
"The code execution cannot proceed because libwinpthread-1.dll was not found."
```
-To resolve these errors:
-1) Copy the following files from mingw-64 on your mac to `C:/windows/System32`:
+To resolve these errors, copy the following files from mingw-64 on your mac to `C:/windows/System32` and re-run:
`/usr/local/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/lib/libatomic-1.dll`
`/usr/local/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/bin/libwinpthread-1.dll`
-2) Register the DLLs on your windows machine using the regsvr32 command:
-`regsvr32 "C:\Windows\System32\libatomic-1.dll"`
-`regsvr32 "C:\Windows\System32\libwinpthread-1.dll"`
-
-`.\prebid-server.exe --sderrthreshold=WARNING =v=2`
### windows amd64 --> windows amd64
Build
@@ -54,48 +48,58 @@ To resolve these errors:
`set GOARCH=amd64`
`go build . && .\prebid-server.exe --stderrthreshold=WARNING -v=2`
-If during the build you get an error similar to:
+You may receive the following error or something similar:
```
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%
```
-install MSYS2:
-1) download the installer (TODO: link)
-2) run the installer
-3) run MSYS2
-4) install windows/amd64 gcc toolchain: `pacman -S --needed base-devel mingw-w64-x86_64-gcc`
-5) enter `Y` when prompted whether to proceed with the installation
-6) Add the path of your MinGW-w64 bin folder to the Windows PATH environment variable by using the following steps:
-- In the Windows search bar, type Settings to open your Windows Settings.
-- Search for Edit environment variables for your account.
-- In your User variables, select the Path variable and then select Edit.
-- Select New and add the MinGW-w64 destination folder you recorded during the installation process to the list. If you used the default settings above, then this will be the path: C:\msys64\ucrt64\bin.
-- Select OK, and then select OK again in the Environment Variables window to update the PATH environment variable. You have to reopen any console windows for the updated PATH environment variable to be available.
-7) confirm gcc installed: `gcc --version`
+To resolve the error, install MSYS2:
+1) Download the installer (https://www.msys2.org/)
+2) Run the installer and follow the steps of the installation wizard
+3) Run MSYS2 which will open an MSYS2 terminal for you
+4) In the MSYS2 terminal, install windows/amd64 gcc toolchain: `pacman -S --needed base-devel mingw-w64-x86_64-gcc`
+5) Enter `Y` when prompted whether to proceed with the installation
+6) Add the path of your MinGW-w64 `bin` folder to the Windows `PATH` environment variable by using the following steps:
+ - In the Windows search bar, type Settings to open your Windows Settings.
+ - Search for Edit environment variables for your account.
+ - In your User variables, select the `Path` variable and then select Edit.
+ - Select New and add the MinGW-w64 destination folder you recorded during the installation process to the list. If you used the default settings above, then this will be the path: `C:\msys64\ucrt64\bin`.
+ - Select OK, and then select OK again in the Environment Variables window to update the `PATH` environment variable. You have to reopen any console windows for the updated `PATH` environment variable to be available.
+7) Confirm gcc installed: `gcc --version`
Run
+Running the built binary on windows:
`go build . && .\prebid-server.exe --stderrthreshold=WARNING -v=2`
-### linux amd64 --> linux amd64
-Tests
-Debian or Ubuntu Linux targeting a Debian-based Linux distribution
+You may receive the following errors or something similar:
+```
+"The code execution cannot proceed because libatomic-1.dll was not found."
+"The code execution cannot proceed because libwinpthread-1.dll was not found."
+```
+To resolve these errors, copy the following files from MSYS2 installation to `C:/windows/System32` and re-run:
+`C:\mysys64\mingw64\bin\libatomic-1.dll`
+`C:\mysys64\mingw64\bin\libwinpthread-1.dll`
+### linux amd64 --> linux amd64
Build
`GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build`
-If during the build you get an error similar to:
+You may receive the following error or something similar:
```
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
```
-install gcc, by running `sudo apt-get install -y gcc`
+To resolve the error, install gcc and re-build:
+`sudo apt-get install -y gcc`
Run
Running the built binary on Linux:
`./prebid-server --stderrthreshold=WARNING -v=2`
-If you get an error:
+
+You may receive the following error or something similar:
```
... error while loading shared libraries: libatomic.so.1: cannot open shared object file ...
```
-install libatomic1, by running `sudo apt-get install -y libatomic1`
\ No newline at end of file
+To resolve the error, install libatomic1 and re-run:
+`sudo apt-get install -y libatomic1`
\ No newline at end of file
From d84d0682d3dabd1244334bb2261647f23aa8a79b Mon Sep 17 00:00:00 2001
From: bsardo <1168933+bsardo@users.noreply.github.com>
Date: Thu, 19 Sep 2024 13:54:55 -0400
Subject: [PATCH 4/6] Move to docs/build folder
---
{run => docs/build}/README.md | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {run => docs/build}/README.md (100%)
diff --git a/run/README.md b/docs/build/README.md
similarity index 100%
rename from run/README.md
rename to docs/build/README.md
From 4791014e32e761654e277b1d73f026a6b0876875 Mon Sep 17 00:00:00 2001
From: bsardo <1168933+bsardo@users.noreply.github.com>
Date: Fri, 20 Sep 2024 09:56:25 -0400
Subject: [PATCH 5/6] Add debian-based distribution note
---
docs/build/README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/docs/build/README.md b/docs/build/README.md
index 3a5e6690044..36d85a65506 100644
--- a/docs/build/README.md
+++ b/docs/build/README.md
@@ -82,6 +82,9 @@ To resolve these errors, copy the following files from MSYS2 installation to `C:
`C:\mysys64\mingw64\bin\libwinpthread-1.dll`
### linux amd64 --> linux amd64
+Note
+These instructions are for building and running on Debian-based distributions
+
Build
`GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build`
From 12385fccc066f93ccb42a30aa54ebfb7461748de Mon Sep 17 00:00:00 2001
From: bsardo <1168933+bsardo@users.noreply.github.com>
Date: Tue, 24 Sep 2024 22:37:56 -0400
Subject: [PATCH 6/6] Included first version where these instructions apply +
format changes
---
docs/build/README.md | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/docs/build/README.md b/docs/build/README.md
index 36d85a65506..0b52671f216 100644
--- a/docs/build/README.md
+++ b/docs/build/README.md
@@ -1,33 +1,33 @@
## Overview
-Prebid Server contains at least one module that requires CGo which introduces both build and runtime dependencies.
-To build, you need a C compiler, preferably gcc.
-To run, you may require one or more runtime dependencies, most notably libatomic.
+As of v2.31.0, Prebid Server contains a module that requires CGo which introduces both build and runtime dependencies. To build, you need a C compiler, preferably gcc. To run, you may require one or more runtime dependencies, most notably libatomic.
-## Examples (Build --> Target)
+## Examples
For a containerized example, see the Dockerfile.
-Here are some manual build examples, including some cross-compilation use cases, that have been tested:
+For manual build examples, including some cross-compilation use cases, see below.
-### darwin amd64 --> darwin amd64
+### From darwin amd64
+
+#### To darwin amd64
`GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build`
Running the built binary on mac amd64:
`./prebid-server --stderrthreshold=WARNING -v=2`
-### darwin amd64 --> darwin arm64
+#### To darwin arm64
`GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build`
Running the built binary on mac arm64:
`./prebid-server --stderrthreshold=WARNING -v=2`
-### darwin amd64 --> windows amd64
-Build (mac)
+#### To windows amd64
+Build
Install mingw-w64 which consists of a gcc compiler port you can use to generate windows binaries:
`brew install mingw-w64`
`GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" go build`
-Run (windows)
+Run
Running the built binary on windows:
`.\prebid-server.exe --sderrthreshold=WARNING =v=2`
@@ -41,7 +41,8 @@ To resolve these errors, copy the following files from mingw-64 on your mac to `
`/usr/local/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/lib/libatomic-1.dll`
`/usr/local/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/bin/libwinpthread-1.dll`
-### windows amd64 --> windows amd64
+### From windows amd64
+#### To windows amd64
Build
`set CGO_ENABLED=1`
`set GOOS=windows`
@@ -81,7 +82,8 @@ To resolve these errors, copy the following files from MSYS2 installation to `C:
`C:\mysys64\mingw64\bin\libatomic-1.dll`
`C:\mysys64\mingw64\bin\libwinpthread-1.dll`
-### linux amd64 --> linux amd64
+### From linux amd64
+#### To linux amd64
Note
These instructions are for building and running on Debian-based distributions