### Initial Go Module Setup Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_tidy_compat_added.txt This is the initial state of the go.mod file for the example module, specifying Go 1.17 and a 'replace' directive for 'example.net/added'. ```go module example.com/m go 1.17 replace ( example.net/added v0.1.0 => ./a1 example.net/added v0.2.0 => ./a2 example.net/added v0.3.0 => ./a1 example.net/lazy v0.1.0 => ./lazy example.net/pruned v0.1.0 => ./pruned ) require ( example.net/added v0.1.0 example.net/lazy v0.1.0 ) ``` -------------------------------- ### Setup and Initial State for Local Module Testing Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_local.txt Sets up the initial state by copying the go.mod file and editing it for formatting. This is a prerequisite for subsequent 'go get' operations. ```bash env GO111MODULE=on go mod edit -fmt cp go.mod go.mod.orig ``` -------------------------------- ### Go Source File Example Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_convert_tsv.txt This is a minimal Go source file used as part of the test setup. ```go -- $WORK/test/x/x.go -- package x // import "m/x" ``` -------------------------------- ### Configuring and Building libgccjit for JIT and General Use Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/doc/libgdiagnostics/internals/index.md This example demonstrates a two-stage build process for GCC with libgccjit. First, configure and build with --enable-host-shared for the JIT, then configure and build without it for maximum speed of other languages. Installation order is important. ```bash # Configure and build with --enable-host-shared # for the jit: mkdir configuration-for-jit pushd configuration-for-jit $(SRCDIR)/configure \ --enable-host-shared \ --enable-languages=jit \ --prefix=$(DESTDIR) make popd # Configure and build *without* --enable-host-shared # for maximum speed: mkdir standard-configuration pushd standard-configuration $(SRCDIR)/configure \ --enable-languages=all \ --prefix=$(DESTDIR) make popd # Both of the above are configured to install to $(DESTDIR) # Install the configuration with --enable-host-shared first # *then* the one without, so that the faster build # of "cc1" et al overwrites the slower build. pushd configuration-for-jit make install popd pushd standard-configuration make install popd ``` -------------------------------- ### Example: Basic Multimap Usage Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/policy_data_structures_design.html Demonstrates the usage of an associative container mapping user IDs to associative containers of application IDs and start times. This is an example of how to implement a multimap-like structure. ```C++ #include #include int main() { using namespace __gnu_pbds; // Map user IDs to associative containers mapping application IDs to start times. // The inner container is a `tree` (red-black tree) mapping application IDs to start times. // The outer container is also a `tree` mapping user IDs to the inner containers. gp_hash_table, rb_tree_tag, tree_order_statistics_node_update> >::type user_app_times; // Example usage: // user_app_times[1000][2000] = 1234567890; // user_app_times[1000][2001] = 1234567891; // user_app_times[1001][2000] = 1234567892; std::cout << "Example of basic multimap usage.\n"; // Actual usage would involve populating and querying the map. return 0; } ``` -------------------------------- ### Go Get Command Example Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_issue37438.txt This command demonstrates fetching a specific version of a module. It's used to test the scenario where the module path might not exist at other versions. ```bash go get example.net/a/p@v0.2.0 ``` -------------------------------- ### Stand-alone CMake Build Example Source: https://github.com/rust-gcc/gccrs/blob/master/libcody/README.md This example demonstrates how to configure and build libCody using CMake in a stand-alone setup. It specifies the installation prefix and the C++ compiler to use. ```bash cmake -DCMAKE_INSTALL_PREFIX=/path/to/installation -DCMAKE_CXX_COMPILER=clang++ /path/to/libcody/source make make install ``` -------------------------------- ### Initial Go Module Setup Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_downup_artifact.txt Sets up the initial Go module structure and dependencies. This includes the main module 'example.com/m' and its direct dependencies on 'a', 'b', 'c', and 'd'. Replace directives are used to point to local versions of these modules. ```go module example.com/m go 1.16 require ( example.com/a v0.1.0 example.com/b v0.1.0 example.com/c v0.1.0 example.com/d v0.1.0 ) replace ( example.com/a v0.1.0 => ./a1 example.com/b v0.1.0 => ./b1 example.com/b v0.2.0 => ./b2 example.com/c v0.1.0 => ./c example.com/c v0.2.0 => ./c example.com/d v0.1.0 => ./d example.com/d v0.2.0 => ./d example.com/e v0.1.0 => ./e ) ``` ```go package m import ( _ "example.com/a" _ "example.com/b" _ "example.com/c" _ "example.com/d" ) ``` ```go module example.com/a go 1.16 require example.com/b v0.1.0 ``` ```go package a import _ "example.com/b" ``` ```go module example.com/b go 1.16 require example.com/c v0.1.0 ``` ```go package b import _ "example.com/c" ``` ```go module example.com/b go 1.16 require ( example.com/c v0.2.0 example.com/d v0.2.0 example.com/e v0.1.0 ) ``` ```go package b import ( "example.com/c" "example.com/d" "example.com/e" ) ``` ```go module example.com/c go 1.16 ``` ```go module example.com/d go 1.16 ``` ```go package d ``` ```go module example.com/e go 1.16 ``` ```go package e ``` -------------------------------- ### Initial Go Get with Ambiguous Package Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_ambiguous_pkg.txt When starting from a clean slate, `go get` resolves an ambiguous package to the module with the longest matching path prefix. This example shows `go get` selecting `example.net/ambiguous/nested/pkg` over `example.net/ambiguous`. ```bash cp go.mod go.mod.orig go get example.net/ambiguous/nested/pkg@v0.1.0 go list -m all stdout '^example.net/ambiguous/nested v0.1.0$' ! stdout '^example.net/ambiguous ' ``` -------------------------------- ### Initial Setup and Versioning Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_tidy_convergence_loop.txt Sets up the initial go.mod file and modifies it to specific Go versions for testing purposes. ```bash cp go.mod.orig go.mod go mod edit -go=1.17 go.mod cp go.mod go.mod.117 go mod edit -go=1.17 go.mod.tidye1 go mod edit -go=1.17 go.mod.tidye2 go mod edit -go=1.17 go.mod.tidye3 go mod edit -go=1.17 go.mod.postget ``` -------------------------------- ### Initial Module Setup Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_load_badchain.txt Sets up the Go module environment by copying an existing go.mod file and downloading initial dependencies to prepare for subsequent tests. ```bash env GO111MODULE=on # Download everything to avoid "finding" messages in stderr later. cp go.mod.orig go.mod go mod download go mod download example.com@v1.0.0 go mod download example.com/badchain/a@v1.1.0 go mod download example.com/badchain/b@v1.1.0 go mod download example.com/badchain/c@v1.1.0 ``` -------------------------------- ### Go Get with Empty SumDB and Fallback Mirror Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_sumdb_file_path.txt Once a checksum is present in the go.sum file, an empty file-based SumDB can be used in conjunction with a fallback module mirror. This example shows the setup and the subsequent `go get` command. ```bash grep golang.org/x/text go.sum env GOPATH=$WORK/gopath3 [windows] env GOPROXY=file:///$WORK/sumproxy [!windows] env GOPROXY=file://$WORK/sumproxy ! go get golang.org/x/text@v0.3.2 [windows] env GOPROXY=file:///$WORK/sumproxy,https://proxy.golang.org [!windows] env GOPROXY=file://$WORK/sumproxy,https://proxy.golang.org go get golang.org/x/text@v0.3.2 ``` -------------------------------- ### Example: Feature Configuration Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/appendix_porting.html Example of configuring a feature 'extra-foo' with a default value of 'yes'. ```autoconf GLIBCXX_ENABLE (extra-foo, yes, =BAR, [turn on extra foo]) ``` -------------------------------- ### Initial Go List Command Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/work_replace_main_module.txt Lists the dependency 'example.com/dep' before applying workspace changes. ```bash go list example.com/dep ``` -------------------------------- ### Install Benign Commit with go get Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/get_dotfiles.txt Uses 'go get -u' to install the benign commit from the 'foo' repository. This verifies that 'go get' works correctly for non-dotfile repositories. ```bash cd $GOPATH go get -u example.com/foo ``` -------------------------------- ### Install Vendored Dependency Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/vendor_test_issue11864.txt Installs a vendored dependency using `go get`. This command is used to fetch and install packages, including those that are vendored. ```go env GO111MODULE=off go get github.com/rsc/go-get-issue-11864 ``` -------------------------------- ### Initial Setup and Verification Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_downadd_indirect.txt Copies the go.mod file, tidies dependencies, and compares the modified go.mod with the original. This step ensures the initial state is clean before proceeding. ```bash cp go.mod go.mod.orig go mod tidy cmp go.mod.orig go.mod ``` -------------------------------- ### Initial Setup and Control Case Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_update_unrelated_sum.txt Sets up the initial state of go.mod and go.sum files and verifies that the existing sums are correct before any module upgrades. ```bash env fmt='{{.ImportPath}}: {{if .Error}}{{.Error.Err}}{{else}}ok{{end}}' # Control case: before upgrading, we have the sums we need. # go list -deps -e -f $fmt . # stdout '^rsc.io/quote: ok$' # ! stdout rsc.io/sampler # not imported by quote in this version cp go.mod.orig go.mod cp go.sum.orig go.sum go mod tidy cmp go.mod.orig go.mod cmp go.sum.orig go.sum ``` -------------------------------- ### Example of Text Output Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/ada/doc/gnat_ugn/about_this_guide.rst This snippet shows how example text output is presented in the guide, typically following a description. ```text and then shown this way. ``` -------------------------------- ### Go Get Missing VCS Error Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_vcs_missing.txt Tests 'go get' behavior when Bazaar is not installed, expecting a specific error. ```bash cd empty ! go get launchpad.net/gocheck stderr '"bzr": executable file not found' ``` -------------------------------- ### Go List Example Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_pkgtags.txt Illustrates using 'go list' to inspect dependencies and build constraints. ```bash go list -deps example.net/cmd/tool ``` -------------------------------- ### Get Specific Module Version and List Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_case.txt Installs a specific pre-release version of a module and then lists all modules to confirm the installation. ```bash go get rsc.io/QUOTE@v1.5.3-PRE go list -m all stdout '^rsc.io/QUOTE v1.5.3-PRE' ``` -------------------------------- ### Module q1_1_0 Go File Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/work_prune_all.txt Implements 'PrintVersion' for 'example.com/q' version 1.1.0, importing 'example.com/w' and 'example.com/z'. ```go package q import _ "example.com/w" import _ "example.com/z" import "fmt" func PrintVersion() { fmt.Println("version 1.1.0") } ``` -------------------------------- ### Unattended GNAT Installation (Custom Directory) Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/ada/doc/gnat_ugn/platform_specific_information.rst Example of performing a silent installation of GNAT into a custom directory using the command line. ```bash gnatpro-19.2-x86-windows-bin /S /D=C:\TOOLS\GNATPRO\19.2 ``` -------------------------------- ### Build Example Executable Source: https://github.com/rust-gcc/gccrs/blob/master/zlib/CMakeLists.txt Compiles the 'example' executable from test/example.c and links it against the zlib library. Also adds it as a test. ```cmake add_executable(example test/example.c) target_link_libraries(example zlib) add_test(example example) ``` -------------------------------- ### Getting CGO Package Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_case_cgo.txt Retrieves the CGO package using 'go get'. This command downloads and installs the specified package and its dependencies. ```bash go get rsc.io/CGO ``` -------------------------------- ### Initial Go install command Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/build_gopath_order.txt Executes 'go install -x bar' to observe the build process and package resolution with the initial GOPATH configuration. ```bash go install -x bar ``` -------------------------------- ### Install zlib Manual Page Source: https://github.com/rust-gcc/gccrs/blob/master/zlib/CMakeLists.txt Installs the zlib.3 manual page to the installation man3 directory. ```cmake install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") ``` -------------------------------- ### Example of Range Representation Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/doc/libgdiagnostics/topics/physical-locations.md Illustrates the source code and line numbering for a range example, showing start, caret, and end points. ```default ...|__________1111111112222222 ...|12345678901234567890123456 ...| 521|int sum (int foo, int bar) 522|{ 523| return foo + bar; ...| ~~~~^~~~~ 524|} ``` -------------------------------- ### Install zlib Pkgconfig File Source: https://github.com/rust-gcc/gccrs/blob/master/zlib/CMakeLists.txt Installs the zlib pkgconfig file to the installation pkgconfig directory. ```cmake install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") ``` -------------------------------- ### Unattended GNAT Installation (Default Directory) Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/ada/doc/gnat_ugn/platform_specific_information.rst Example of performing a silent installation of GNAT 19.2 into the default directory using the command line. ```bash gnatpro-19.2-x86-windows-bin /S ``` -------------------------------- ### Initial Setup and Verification Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/work_sync_sum.txt Copies the go.sum file, tidies the module, and compares the original with the tidied version to ensure consistency before running 'go work sync'. ```bash cp b/go.sum b/go.sum.want # As a sanity check, verify b/go.sum is tidy. cd b go mod tidy cd .. cmp b/go.sum b/go.sum.want ``` -------------------------------- ### Example x.go file content Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_tidy_too_new.txt A simple Go package 'x' with an import statement for module 'example.net/m'. ```go package x import "example.net/m" ``` -------------------------------- ### Go Get with Multi-line Retraction Rationale (Second Example) Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_retract_rationale.txt This demonstrates that 'go get' output is consistent regardless of where the retraction is defined (top-level or block). ```go go get example.com/retract/rationale@v1.0.0-multiline2 stderr '^go: warning: example.com/retract/rationale@v1.0.0-multiline2: retracted by module author: short description$' ! stderr 'detail' ``` -------------------------------- ### Example: Shell Code Handler Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/appendix_porting.html Example demonstrating the use of shell code to handle enable/disable options. ```autoconf GLIBCXX_ENABLE (CXX_FLAGS, yes, [], [enable C++ flags], "if test \"$CXX_FLAGS\" = \"yes\"; then echo \"Warning: CXX_FLAGS=yes is not a valid setting.\" >&2; configure_failed=yes; fi") ``` -------------------------------- ### Example x/x.go file content Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_tidy.txt A Go source file for package 'x' with an import for 'w.1'. ```go package x import _ "w.1" ``` -------------------------------- ### Setup for Module Mode Insecure Get Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/get_insecure.txt Sets up the environment for testing 'go get' with modules, including disabling GOPROXY and setting GO111MODULE to 'on'. ```bash # Modules: Set up env GOPATH=$WORK/m/gp mkdir $WORK/m cp module_file $WORK/m/go.mod cd $WORK/m env GO111MODULE=on env GOPROXY='' ``` -------------------------------- ### Install zlib Public Headers Source: https://github.com/rust-gcc/gccrs/blob/master/zlib/CMakeLists.txt Installs the public header files for zlib to the installation include directory. ```cmake install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") ``` -------------------------------- ### Build 64-bit Example Executable Source: https://github.com/rust-gcc/gccrs/blob/master/zlib/CMakeLists.txt Compiles a 64-bit version of the 'example' executable with the _FILE_OFFSET_BITS=64 compile flag and links it against zlib. Adds it as a test. ```cmake add_executable(example64 test/example.c) target_link_libraries(example64 zlib) set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") add_test(example64 example64) ``` -------------------------------- ### Install echo command for Windows Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/generate_invalid.txt Installs a simple 'echo' command using Go, as it's not natively available on Windows. This is a setup step for subsequent tests. ```bash env GOBIN=$WORK/tmp/bin go install echo.go env PATH=$GOBIN${:}$PATH ``` -------------------------------- ### Initial Setup and Tidy Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_tidy_convergence.txt Copies the original go.mod, edits it for Go 1.17, and then runs `go mod tidy -e` to observe the tidied state. Compares the result with a reference file. ```bash cp go.mod.orig go.mod go mod edit -go=1.17 go.mod go mod edit -go=1.17 go.mod.tidye go mod tidy -e cmp go.mod go.mod.tidye ``` -------------------------------- ### Upgrading Dependencies with 'go get' Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_tidy_convergence_loop.txt Upgrades specific versions of example modules using 'go get'. This is a precursor to observing the effects of 'go mod tidy -e'. ```bash go get example.net/w@v0.2.0-pre example.net/x@v0.2.0-pre example.net/y@v0.2.0-pre example.net/z@v0.2.0-pre ``` -------------------------------- ### Basic Go Module Setup Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_replace_import.txt Initial setup for testing module replacement functionality. This involves copying the go.mod file and verifying its integrity. ```bash env GO111MODULE=on # 'go list' should not add requirements even if they can be resolved locally. cp go.mod go.mod.orig ! go list all cmp go.mod go.mod.orig ``` -------------------------------- ### Example: Permitted Values Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/appendix_porting.html Example allowing specific values for a feature, including 'yes' and 'no'. ```autoconf GLIBCXX_ENABLE (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit generic|gnu|ieee_1003.1-2001|yes|no|auto) ``` -------------------------------- ### Include Directory Options Example Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/source_design_notes.html Demonstrates additive include directory options with prefixing and conditional searching. This example shows how to specify include paths that are searched after standard system directories and how to control pedantic warning behavior for included files. ```bash -pedantic -iprefix $(prefix) \ -idirafter -ino-pedantic -ino-extern-c -iwithprefix -I g++-v3 \ -iwithprefix -I g++-v3/ext ``` -------------------------------- ### Install and List Module Dependencies Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_symlink.txt Installs dependencies for the current module and lists the module information for its dependencies. Verifies that 'go get' correctly resolves imported packages. ```bash go get go list -deps -f '{{.Module}}' . ``` ```bash go get ./subpkg go list -deps -f '{{.Module}}' ./subpkg ``` -------------------------------- ### SIMD Test Suite Directives Examples Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/testsuite/experimental/simd/README.md Examples demonstrating how to use directives to control test execution based on type, ABI, target, and CXXFLAGS. ```cpp // The test is only valid for floating-point types: // only: float|double|ldouble * * * ``` ```cpp // Skip the test for long double for all powerpc64* targets: // skip: ldouble * powerpc64* * ``` ```cpp // The test is expected to unconditionally fail on execution: // xfail: run * * * * ``` ```cpp // ABI subsets 1-9 are considered expensive: // expensive: * [1-9] * * ``` -------------------------------- ### Initial Setup and Verification Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_lazy_downgrade.txt Sets up the initial module state and verifies the expected versions of modules after 'go mod tidy'. ```bash cp go.mod go.mod.orig go mod tidy cmp go.mod.orig go.mod ``` ```bash go list -m all stdout '^example.com/a v0.1.0 ' stdout '^example.com/b v0.3.0 ' stdout '^example.com/c v0.2.0 ' ``` -------------------------------- ### Get Executable Starting Address with objdump Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/ada/doc/gnat_ugn/platform_specific_information.rst Use objdump to find the starting address of an executable. This address is needed to set a breakpoint at the program's entry point. ```bash $ objdump --file-header main.exe ``` -------------------------------- ### Example CHECK_SIMD_CONFIG script for powerpc64le Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/testsuite/experimental/simd/README.md This shell script example shows how to define custom targets with specific CPU flags and simulators for powerpc64le architectures, and then sets the `target_list` accordingly. ```sh powerpc64le-*) define_target power7 "-mcpu=power7 -static" "$HOME/bin/run_on_gccfarm gcc112" define_target power8 "-mcpu=power8 -static" "$HOME/bin/run_on_gccfarm gcc112" define_target power9 "-mcpu=power9 -static" "$HOME/bin/run_on_gccfarm gcc135" target_list="power7 power8 power9{,-ffast-math}" ;; ``` -------------------------------- ### Install zlib Libraries Source: https://github.com/rust-gcc/gccrs/blob/master/zlib/CMakeLists.txt Installs the zlib and zlibstatic targets to the appropriate runtime, archive, and library directories. ```cmake install(TARGETS zlib zlibstatic RUNTIME DESTINATION "${INSTALL_BIN_DIR}" ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) ``` -------------------------------- ### Example with verbose terminate handler Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/termination.html An example program that throws different types of exceptions, demonstrating the output of the verbose terminate handler when active. ```c++ #include #include struct argument_error : public std::runtime_error { argument_error(const std::string& s): std::runtime_error(s) { } }; int main(int argc) { std::set_terminate(__gnu_cxx::__verbose_terminate_handler); if (argc > 5) throw argument_error("argc is greater than 5!"); else throw argc; } ``` -------------------------------- ### Initialize and Configure Git Repositories Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/get_brace.txt Sets up two empty Git repositories, 'foo' and '{confusing}', with basic user configuration and an initial commit. This is a prerequisite for testing Go module behavior with specific repository names. ```bash env GO111MODULE=off [!exec:git] skip # Set up some empty repositories. cd $WORK/_origin/foo exec git init exec git config user.name 'Nameless Gopher' exec git config user.email 'nobody@golang.org' exec git commit --allow-empty -m 'create master branch' cd $WORK cd '_origin/{confusing}' exec git init exec git config user.name 'Nameless Gopher' exec git config user.email 'nobody@golang.org' exec git commit --allow-empty -m 'create master branch' ``` -------------------------------- ### Setting GO111MODULE and Running go get Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_domain_root.txt Sets the GO111MODULE environment variable to 'on' and then executes the 'go get' command. This is a common setup for managing Go modules. ```bash env GO111MODULE=on go get ``` -------------------------------- ### Run Configure Script Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/appendix_porting.html Start the configuration process for building libstdc++ by executing the configure script. ```shell configure ``` -------------------------------- ### Example CHECK_SIMD_CONFIG script for powerpc64 Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/testsuite/experimental/simd/README.md This shell script example defines custom targets for powerpc64 architectures and configures the `target_list` to include variations with fast math flags. ```sh powerpc64-*) define_target power7 "-mcpu=power7 -static" "$HOME/bin/run_on_gccfarm gcc110" define_target power8 "-mcpu=power8 -static" "$HOME/bin/run_on_gccfarm gcc110" target_list="power7 power8{,-ffast-math}" ;; ``` -------------------------------- ### Initial Setup and Tidy Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_lazy_new_import.txt Copies initial module and main package files, then runs 'go mod tidy' to ensure the module is in a clean state before modifications. Verifies that the go.mod file remains unchanged. ```bash cp go.mod go.mod.old cp lazy.go lazy.go.old go mod tidy cmp go.mod go.mod.old ``` -------------------------------- ### Install 'env' command for Windows and Plan9 Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/generate_env.txt Installs the 'env' command, which is not natively available on Windows and Plan9. This setup ensures environment variables can be managed correctly on these platforms. ```go env GOBIN=$WORK/tmp/bin go install env.go ``` -------------------------------- ### Initial Module Setup Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_prefer_incompatible.txt Sets up the initial state of the go.mod file with an incompatible module version. ```bash cp go.mod go.mod.orig go mod tidy cmp go.mod.orig go.mod grep '^example.com/incompatiblewithsub v2\.0\.0\+incompatible' go.sum ! grep '^example.com/incompatiblewithsub v1.0.0' go.sum ``` -------------------------------- ### Handling Multi-line Deprecation Messages with 'go get' Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_deprecate_message.txt For modules with multi-line deprecation messages, 'go get' truncates the output to display only the first line. This example shows the expected 'go get' output and verifies that the second line is not printed by 'go get' but is available via 'go list'. ```go go get multiline stderr '^go: module multiline is deprecated: first line$' ! stderr 'second line' go list -m -u -f '{{.Deprecated}}' multiline stdout '^first line second line.$' ``` -------------------------------- ### Install Binary MO Files Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/facets.html Copy the compiled MO files into the correct directory structure for the locale, making them accessible to the runtime environment. ```bash cp fr_FR.mo (dir)/fr_FR/LC_MESSAGES/libstdc++.mo ``` ```bash cp de_DE.mo (dir)/de_DE/LC_MESSAGES/libstdc++.mo ``` -------------------------------- ### Example CHECK_SIMD_CONFIG script for x86_64 Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/testsuite/experimental/simd/README.md This shell script example demonstrates how to set the `target_list` variable based on the target triplet for x86_64 architectures, enabling different optimization flags for SIMD tests. ```sh case "$target_triplet" in x86_64-*) target_list="unix{-march=sandybridge,-march=skylake-avx512,-march=native/-ffast-math,-march=athlon64,-march=core2,-march=nehalem,-march=skylake,-march=native/-ffinite-math-only,-march=knl}" ;; esac ``` -------------------------------- ### zpipe Usage Example Source: https://github.com/rust-gcc/gccrs/blob/master/zlib/examples/zlib_how.html This snippet shows the basic command-line usage for the zpipe utility, which is a simple example program for zlib. It indicates how to specify decompression with the -d flag and how to redirect input and output. ```c #define SET_BINARY_MODE(file) } /* otherwise, report usage */ else { fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr); return 1; } } ``` -------------------------------- ### Go Get with Module Off (Reproducing Issue) Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/get_404_meta.txt This snippet demonstrates reproducing the issue with GO111MODULE set to 'off'. It uses 'go get -d' to download dependencies without installing them. ```bash env GONOSUMDB=bazil.org,github.com,golang.org env GO111MODULE=off go get -d bazil.org/fuse/fs/fstestutil ``` -------------------------------- ### Module q1_0_5 Go File Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/work_prune_all.txt A placeholder for 'example.com/q' version 1.0.5, which imports 'example.com/r'. ```go package q import _ "example.com/r" ``` -------------------------------- ### Map Example with cc_hash_table Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/policy_data_structures_design.html An example of a map using cc_hash_table, mapping integer keys to character values. ```cpp cc_hash_table ``` -------------------------------- ### Running the Toy VM Example Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/doc/libgdiagnostics/intro/tutorial04.md Demonstrates running the compiled toyvm with factorial and fibonacci scripts, comparing interpreter and compiler results. ```console $ ./toyvm factorial.toy 10 interpreter result: 3628800 compiler result: 3628800 $ ./toyvm fibonacci.toy 10 interpreter result: 55 compiler result: 55 ``` -------------------------------- ### Install echo command for Windows Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/generate.txt Installs the 'echo.go' program to a temporary bin directory and adds it to the PATH. This is a setup step for Windows environments lacking a native echo command. ```bash env GOBIN=$WORK/tmp/bin go install echo.go env PATH=$GOBIN:${PATH} ``` -------------------------------- ### Main Module Configuration Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_downadd_indirect.txt Defines the main module 'example.com/a' and its initial dependencies. Includes 'replace' directives to map module versions to local paths, crucial for testing local module variations. ```go module example.com/a go 1.15 require example.com/b v0.2.0 replace ( example.com/b v0.1.0 => ./b1 example.com/b v0.2.0 => ./b2 example.com/c v0.1.0 => ./c example.com/d v0.1.0 => ./d example.com/d v0.2.0 => ./d ) ``` -------------------------------- ### Go Get with Module On (Corrected Behavior) Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/get_404_meta.txt This snippet shows the corrected behavior with GO111MODULE set to 'on' and GOPROXY set to 'direct'. It uses 'go get' to download and install dependencies. ```bash env GO111MODULE=on env GOPROXY=direct go get bazil.org/fuse/fs/fstestutil ``` -------------------------------- ### Run Tests with Installed Compiler and Library Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/test.html Execute the libstdc++ testsuite using an already installed compiler and library. Ensure the compiler is in PATH and shared libraries are in LD_LIBRARY_PATH. ```bash runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite ``` -------------------------------- ### C++ mt_allocator Tunable Parameters Example Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/mt_allocator_impl.html Demonstrates how to initialize and use tunable parameters for the `__gnu_cxx::__mt_alloc` allocator. Shows setting options using `_M_set_options` and retrieving them with `_M_get_options` before performing allocations and deallocations. ```cpp #include struct pod { int i; int j; }; int main() { typedef pod value_type; typedef __gnu_cxx::__mt_alloc allocator_type; typedef __gnu_cxx::__pool_base::_Tune tune_type; tune_type t_default; tune_type t_opt(16, 5120, 32, 5120, 20, 10, false); tune_type t_single(16, 5120, 32, 5120, 1, 10, false); tune_type t; t = allocator_type::_M_get_options(); allocator_type::_M_set_options(t_opt); t = allocator_type::_M_get_options(); allocator_type a; allocator_type::pointer p1 = a.allocate(128); allocator_type::pointer p2 = a.allocate(5128); a.deallocate(p1, 128); a.deallocate(p2, 5128); return 0; } ``` -------------------------------- ### Module A Source File Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_patchbound.txt Source file for module `example.net/a`. ```go -- a/a.go -- package a import _ "example.net/b" ``` -------------------------------- ### Package definition for 'example.com/x' (v0.2.0) Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_lazy_consistency.txt Defines the 'x' package for version v0.2.0, introducing a new constant 'AddedInV2'. ```go package x const AddedInV2 = true ``` -------------------------------- ### Example GNAT Target Parameterization File Source: https://github.com/rust-gcc/gccrs/blob/master/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst An example of a complete target parameterization file for GNAT, listing system variables and floating-point type definitions. This file guides the compiler's target-specific configurations. ```text Bits_BE 0 Bits_Per_Unit 8 Bits_Per_Word 64 Bytes_BE 0 Char_Size 8 Double_Float_Alignment 0 Double_Scalar_Alignment 0 Double_Size 64 Float_Size 32 Float_Words_BE 0 Int_Size 64 Long_Double_Size 128 Long_Long_Long_Size 128 Long_Long_Size 64 Long_Size 64 Maximum_Alignment 16 Max_Unaligned_Field 64 Pointer_Size 64 Short_Size 16 Strict_Alignment 0 System_Allocator_Alignment 16 Wchar_T_Size 32 Words_BE 0 float 15 I 64 64 double 15 I 64 64 long double 18 I 80 128 TF 33 I 128 128 ``` -------------------------------- ### Example: Basic Multiset Usage Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/policy_data_structures_design.html Illustrates the usage of an associative container mapping integers to a size type, representing the count of occurrences. This serves as an example for implementing a multiset-like structure. ```C++ #include #include int main() { using namespace __gnu_pbds; // Map integers to a size_type representing the number of times they occur. // The container is a `tree` (red-black tree) mapping integers to their counts. tree, rb_tree_tag, tree_order_statistics_node_update> int_counts; // Example usage: // int_counts[1000]++; // int_counts[1000]++; // int_counts[1001]++; std::cout << "Example of basic multiset usage.\n"; // Actual usage would involve populating and querying the counts. return 0; } ``` -------------------------------- ### Package using 'example.net/x' Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_lazy_consistency.txt A Go package 'usex' that imports 'example.net/x'. This is used to test direct dependency loading. ```go package usex import _ "example.net/x" ``` -------------------------------- ### Set Example with cc_hash_table and null_type Source: https://github.com/rust-gcc/gccrs/blob/master/libstdc++-v3/doc/html/manual/policy_data_structures_design.html An example of a set using cc_hash_table, where null_type indicates that keys are stored uniquely without associated mapped values. ```cpp cc_hash_table ``` -------------------------------- ### Initialize and Verify Empty Go Module Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_init_empty.txt Sets up an environment for an empty Go module, initializes it, and then lists the module to verify. ```bash env GO111MODULE=on env GOPATH=$devnull go list -m stdout '^example.com$' go list stdout '^example.com$' ``` -------------------------------- ### Go Get with Existing Shorter Path Dependency Source: https://github.com/rust-gcc/gccrs/blob/master/libgo/go/cmd/go/testdata/script/mod_get_ambiguous_pkg.txt If the module dependencies already include the shorter path prefix, `go get` may retain the existing dependency when encountering an ambiguous package, as it's a valid interpretation. This example shows `go get` keeping `example.net/ambiguous` when `example.net/ambiguous/nested/pkg` is requested. ```bash cp go.mod.orig go.mod go mod edit -require=example.net/ambiguous@v0.1.0 go get example.net/ambiguous/nested/pkg@v0.1.0 go list -m all stdout '^example.net/ambiguous v0.1.0$' ! stdout '^example.net/ambiguous/nested ' ```