### Install Go Module Example Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_import_v1suffix.txt Use 'go get' to download and install a specific version of a Go module. Note that 'example.com/invalidpath/v1' is used here as a placeholder and may result in an error if the path is not valid. ```bash ! go get example.com/invalidpath/v1 ``` -------------------------------- ### Build Example Binaries Source: https://github.com/autc04/retro68/blob/master/binutils/zlib/CMakeLists.txt Compiles example and minigzip utilities, including 64-bit variants if supported. ```cmake add_executable(example test/example.c) target_link_libraries(example zlib) add_test(example example) add_executable(minigzip test/minigzip.c) target_link_libraries(minigzip zlib) if(HAVE_OFF64_T) 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) add_executable(minigzip64 test/minigzip.c) target_link_libraries(minigzip64 zlib) set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") endif() ``` -------------------------------- ### Install a module Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/version_replace.txt Use 'go install' to compile and install a module. This makes the module's commands available in your $GOPATH/bin. ```bash go install example.com/printversion ``` -------------------------------- ### Install Helper Utilities for Mtime Checks Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/build_issue6480.txt Installs 'now', 'mtime', and 'before' utilities to the GOBIN directory. These utilities are used to capture current time, get file modification times, and compare timestamps, respectively. ```go env GOBIN=$WORK/tmp/bin go install m/now m/mtime m/before ``` -------------------------------- ### Install Go Package Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/install_relative_gobin_fail.txt Use 'go install' to build and install Go packages. This command requires GOBIN to be an absolute path. ```shell ! go install ``` -------------------------------- ### Install Go package Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/test_main_archive.txt Install the 'main_test' package. This command compiles and installs the package, making it available for use by other Go programs. ```bash go install main_test ``` -------------------------------- ### Install libffi Source: https://github.com/autc04/retro68/blob/master/gcc/libffi/README.md Run 'make install' to install the libffi library and header files on your system. ```shell make install ``` -------------------------------- ### Install Executable Source: https://github.com/autc04/retro68/blob/master/LaunchAPPL/Client/CMakeLists.txt Installs the 'LaunchAPPL' executable to the 'bin' directory within the runtime destination. ```cmake install(TARGETS LaunchAPPL RUNTIME DESTINATION bin) ``` -------------------------------- ### Install Benign Commit with 'go get' Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/get_dotfiles.txt Uses 'go get -u' to install the latest commit from the benign repository. This verifies that standard repositories are handled correctly. ```bash cd $GOPATH go get -u example.com/foo ``` -------------------------------- ### Build and Run the ToyVM Example Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/jit/docs/intro/tutorial04.md Commands to list files, compile the toyvm source, and execute it with sample scripts. ```console $ ls -al drwxrwxr-x. 2 david david 4096 Sep 19 17:46 . drwxrwxr-x. 3 david david 4096 Sep 19 15:26 .. -rw-rw-r--. 1 david david 615 Sep 19 12:43 factorial.toy -rw-rw-r--. 1 david david 834 Sep 19 13:08 fibonacci.toy -rw-rw-r--. 1 david david 238 Sep 19 14:22 Makefile -rw-rw-r--. 1 david david 16457 Sep 19 17:07 toyvm.c $ make toyvm g++ -Wall -g -o toyvm toyvm.c -lgccjit $ ./toyvm factorial.toy 10 interpreter result: 3628800 compiler result: 3628800 $ ./toyvm fibonacci.toy 10 interpreter result: 55 compiler result: 55 ``` -------------------------------- ### Go module initialization example Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_edit.txt Example of a go.mod file after initialization, specifying the module path and Go version. ```go module x.x/y/z go $goversion ``` -------------------------------- ### Example DLL Exports Section Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/ada/doc/gnat_ugn/platform_specific_information.rst This is an example of the EXPORTS section in a DLL definition file for 'API.dll', listing the symbols 'some_var' and 'get'. ```text EXPORTS some_var get ``` -------------------------------- ### Get Go Module Dependencies Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_case.txt Use 'go get' to download and install dependencies. Ensure GO111MODULE is set to 'on' for module mode. ```bash env GO111MODULE=on go get ``` -------------------------------- ### Get specific module versions Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/version_replace.txt Use 'go get' to download and install specific module versions. This command updates the go.mod and go.sum files. ```bash go get example.com/printversion@v0.1.0 ``` -------------------------------- ### Go Module Configuration Files Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_upgrade.txt Example go.mod files and a Go source file demonstrating module imports. ```text -- go.mod -- module x require rsc.io/quote v1.1.0 ``` ```text -- go.mod-v1.5.1 -- module x require rsc.io/quote v1.5.1 ``` ```go -- use.go -- package use import _ "rsc.io/quote" ``` -------------------------------- ### Define Go module configuration Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/list_swigcxx.txt Sets up the go.mod file for the example module. ```text -- go.mod -- module example go 1.16 ``` -------------------------------- ### Get a chronologically newer pseudo-version Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_list_upgrade_pseudo.txt Fetch a specific pseudo-version using `go get`. This example uses a version that is chronologically newer than the latest tag. ```go go get example.com/pseudoupgrade@v0.0.0-20190430073000-30950c05d534 ``` -------------------------------- ### Ada Procedure Example for Traceback Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst A minimal Ada procedure example. This snippet is often used as a placeholder or starting point for demonstrating traceback functionality. ```ada procedure STB is ``` -------------------------------- ### LaunchAPPL Configuration File Example Source: https://context7.com/autc04/retro68/llms.txt Example configuration file for LaunchAPPL, specifying default emulator and paths. Supports different emulators and connection types. ```ini # ~/.LaunchAPPL.cfg - Configuration file example # Use Mini vMac as default emulator emulator = minivmac minivmac-dir = /path/to/minivmac/ minivmac-path = ./Mini vMac minivmac-rom = ./vMac.ROM system-image = ./System7.dsk autquit7-image = ./autquit7-1.4.1.dsk # Alternative: Serial connection to real Mac # emulator = serial # serial-port = /dev/ttyUSB0 # serial-baud = 19200 # Alternative: TCP connection # emulator = tcp # tcp-address = 192.168.0.42 ``` -------------------------------- ### Project Configuration and Test Files Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_why.txt Example project structure including go.mod and test files used for dependency analysis. ```text -- go.mod -- module mymodule require rsc.io/quote v1.5.2 -- x/x.go -- package x import _ "mymodule/z" -- y/y.go -- package y -- y/y_test.go -- package y import _ "rsc.io/quote" -- z/z.go -- package z import _ "mymodule/y" ``` -------------------------------- ### Go Get Dependency with Missing VCS Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_vcs_missing.txt Attempts to get a dependency using 'go get' in a directory with no version control system initialized. This example shows the expected error when the VCS (like bzr) is not found. ```bash cd empty ! go get launchpad.net/gocheck stderr '"bzr": executable file not found' ``` -------------------------------- ### Go Get: Ignore Test Dependencies Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_test.txt By default, 'go get' ignores test dependencies. This example shows how to verify that test dependencies are not added to go.mod. ```bash env GO111MODULE=on cp go.mod.empty go.mod go get m/a ! grep rsc.io/quote go.mod ``` -------------------------------- ### Module Configuration Files Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_update_sum_readonly.txt Example go.mod and go.sum files for the test case. ```text -- go.mod -- module m go 1.16 require rsc.io/breaker v1.0.0 -- go.sum -- rsc.io/breaker v1.0.0/go.mod h1:s5yxDXvD88U1/ESC23I2FK3Lkv4YIKaB1ij/Hbm805g= ``` -------------------------------- ### Get Go Module Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_build_versioned.txt Use `go get` to download and install a specific version of a Go module. Ensure GO111MODULE is set to 'on' for module support. ```bash env GO111MODULE=on go get rsc.io/fortune/v2 ``` -------------------------------- ### Set up Test Directories and Copy Source Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/install_shadow_gopath.txt Creates necessary directories within the GOPATH and copies the main Go source file to a specific test location. ```bash mkdir $WORK/gopath1/src/test mkdir $WORK/gopath2/src/test cp main.go $WORK/gopath2/src/test/main.go cd $WORK/gopath2/src/test ``` -------------------------------- ### Go Get Command Examples Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_trailing_slash.txt Illustrates `go get` behavior with package paths ending in ".go" and ".go/", with and without version specifiers. `go get` is used to fetch packages. ```bash go get example.com/dotgo.go ``` ```bash go get example.com/dotgo.go/ ``` ```bash go get example.com/dotgo.go@v1.0.0 ``` ```bash go get example.com/dotgo.go/@v1.0.0 ``` -------------------------------- ### Initialize Go Module Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_edit.txt Demonstrates initializing a new module with a specific path and handling initialization errors. ```bash env GO111MODULE=on ! go mod init stderr 'cannot determine module path' ! exists go.mod go mod init x.x/y/z stderr 'creating new go.mod: module x.x/y/z' cmpenv go.mod $WORK/go.mod.init ! go mod init cmpenv go.mod $WORK/go.mod.init ``` -------------------------------- ### Compile and Run Example Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/jit/docs/intro/tutorial02.md This command line shows how to compile the C code using GCC, linking against the libgccjit library, and then how to execute the compiled program. ```console $ gcc \ tut02-square.c \ -o tut02-square \ -lgccjit # Run the built program: $ ./tut02-square result: 25 ``` -------------------------------- ### Go Get -t: Include Test Dependencies Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_test.txt Using 'go get -t' includes test dependencies of the named package. This example verifies that test dependencies are added to go.mod. ```bash cp go.mod.empty go.mod go get -t m/a grep 'rsc.io/quote v1.5.2$' go.mod ``` -------------------------------- ### Go Get All: Consider Test Dependencies Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_test.txt The 'go get all' command considers test dependencies, regardless of whether the '-t' flag is used. This example verifies that test dependencies are included when fetching all packages. ```bash cp go.mod.empty go.mod go get all grep 'rsc.io/quote v1.5.2$' go.mod ``` -------------------------------- ### Example Vendor and Main Go Files Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_go_version_missing.txt Illustrates the content of a vendored dependency file and a main package file, including imports and constants. ```go package dep import _ "example.com/badedit" ``` ```go package m import _ "example.com/dep" const x = 1_000 ``` -------------------------------- ### Sample Go helloworld program Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/gopath_install.txt A simple Go program used for testing installation paths. ```go package main func main() { println("hello world") } ``` -------------------------------- ### Use Pragma Abort_Defer Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst Example of using Abort_Defer at the start of a statement sequence to add a polling point. ```ada -- Add a polling point to check for task aborts begin pragma Abort_Defer; end; ``` -------------------------------- ### Module Q (v1.0.0) Implementation Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/work_prune.txt The Go source file for version 1.0.0 of the `example.com/q` module, which prints its version string. ```go package q import "fmt" func PrintVersion() { fmt.Println("version 1.0.0") } ``` -------------------------------- ### Module Q (v1.1.0) Implementation Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/work_prune.txt The Go source file for version 1.1.0 of the `example.com/q` module, which prints its version string. ```go package q import "fmt" func PrintVersion() { fmt.Println("version 1.1.0") } ``` -------------------------------- ### Go Get Nested Module Resolution Error Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_nopkgs.txt For patterns that could potentially match nested modules, 'go get' should report a module resolution error. This example shows a control case and the expected error output. ```bash go get example.net/emptysubdir/... ! go get example.net/emptysubdir/subdir/... ! stderr 'matched no packages' stderr '^go: example\.net/emptysubdir/subdir/\.\.\.: module example\.net/emptysubdir/subdir: reading http://.*: 404 Not Found\n\tserver response: 404 page not found\n\z' ``` -------------------------------- ### Limit Upgrades with `go get -u` Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_downgrade.txt Use `go get -u` with specific module versions to upgrade only those modules, leaving others unchanged. This example upgrades `rsc.io/quote` to v1.4.0 and `rsc.io/sampler` to v1.0.0, while `golang.org/x/text` is not upgraded. ```bash cp go.mod.empty go.mod go get -u rsc.io/quote@v1.4.0 rsc.io/sampler@v1.0.0 go list -m all stdout 'rsc.io/quote v1.4.0' stdout 'rsc.io/sampler v1.0.0' ! stdout golang.org/x/text ``` -------------------------------- ### Go Source File Example Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_downgrade_missing.txt A sample Go source file demonstrating an import of a sub-package from a module. ```go package m import _ "example.net/pkgadded/subpkg" ``` -------------------------------- ### Module 'example.net/b' test file Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_wild.txt Test file for module 'example.net/b' in the 'b2' directory, importing 'example.net/a'. ```go package b_test import _ "example.net/a" ``` -------------------------------- ### Test Environment and Dependency Setup Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/get_race.txt Configures the test environment by skipping unsupported platforms and installing the required race-enabled dependency. ```text [!net] skip [!exec:git] skip [!race] skip env GO111MODULE=off go get -race github.com/rsc/go-get-issue-9224-cmd ``` -------------------------------- ### Go Get -t -u: Update Test Dependencies Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_test.txt The 'go get -t -u' command updates test dependencies of the named package. This example first requires a specific version and then updates, verifying the new version in go.mod. ```bash cp go.mod.empty go.mod go mod edit -require=rsc.io/quote@v1.5.1 go get -t -u m/a grep 'rsc.io/quote v1.5.2$' go.mod ``` -------------------------------- ### Module Configuration Files Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_file_proxy.txt Example go.mod, source, and go.sum files for testing module dependencies. ```text -- $WORK/x/go.mod -- module x go 1.13 require rsc.io/quote v1.5.1 -- $WORK/x/x.go -- package x import _ "rsc.io/quote" -- $WORK/x/go.sum -- golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= rsc.io/quote v1.5.1 h1:ZE3OgnVGrhXtFkGw90HwW992ZRqcdli/33DLqEYsoxA= rsc.io/quote v1.5.1/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= ``` -------------------------------- ### Main package import Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_wild.txt Example Go file for the main module, importing package 'example.net/a'. ```go package example import _ "example.net/a" ``` -------------------------------- ### Go Get -t: Exclude Imported Test Dependencies Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_test.txt When using 'go get -t', test dependencies of imported packages (including those imported from tests) are not considered. This example confirms that test dependencies of imported packages are not added to go.mod. ```bash cp go.mod.empty go.mod go get -t m/b ! grep rsc.io/quote go.mod ``` -------------------------------- ### Project Configuration Files Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_vendor_replace.txt Configuration files for the module replacement example. ```text -- go.mod -- module example.com/replace require rsc.io/quote/v3 v3.0.0 replace rsc.io/quote/v3 => ./local/not-rsc.io/quote/v3 -- imports.go -- package replace import _ "rsc.io/quote/v3" -- local/not-rsc.io/quote/v3/go.mod -- module not-rsc.io/quote/v3 -- local/not-rsc.io/quote/v3/quote.go -- package quote ``` -------------------------------- ### Go Get -t -u: Do Not Add/Update Imported Test Dependencies Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_test.txt Using 'go get -t -u' does not add or update test dependencies of imported packages. This example demonstrates that even with the update flag, dependencies of imported packages remain unchanged. ```bash cp go.mod.empty go.mod go get -t -u m/b ! grep rsc.io/quote go.mod ``` ```bash go mod edit -require=rsc.io/quote@v1.5.1 go get -t -u m/b grep 'rsc.io/quote v1.5.1$' go.mod ``` -------------------------------- ### Module 'example.net/a' go.mod (v0.1.0) Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_wild.txt go.mod file for module 'example.net/a' at version v0.1.0. ```go module example.net/a go 1.16 ``` -------------------------------- ### Build libCody with CMake Source: https://github.com/autc04/retro68/blob/master/gcc/libcody/README.md Example of building libCody using CMake and Make in a stand-alone configuration. Ensure to specify the installation prefix and C++ compiler. ```bash cmake -DCMAKE_INSTALL_PREFIX=/path/to/installation -DCMAKE_CXX_COMPILER=clang++ /path/to/libcody/source make make install ``` -------------------------------- ### Download Module with JSON Output Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_download.txt Example of using 'go mod download' with the -json flag to get detailed error information in JSON format. ```bash ! go mod download -json bad/path stdout '^\t"Error": "module bad/path: not a known dependency"' ``` -------------------------------- ### Example Go Module Files Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_go_version_missing.txt These are example content for go.mod, go.mod.untidy, and go.mod.tidy files, illustrating different states of module requirements and directives. ```go module example.com/m require example.com/dep v0.1.0 replace ( example.com/dep v0.1.0 => ./dep example.com/testdep v0.1.0 => ./testdep ) ``` ```go module example.com/m go $goversion require example.com/dep v0.1.0 require example.com/testdep v0.1.0 // indirect replace ( example.com/dep v0.1.0 => ./dep example.com/testdep v0.1.0 => ./testdep ) ``` ```go module example.com/m go $goversion require example.com/dep v0.1.0 replace ( example.com/dep v0.1.0 => ./dep example.com/testdep v0.1.0 => ./testdep ) ``` -------------------------------- ### Resolve Ambiguous Package from Clean State Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_ambiguous_pkg.txt Demonstrates how 'go get' resolves a package from a module with the longest matching prefix when starting from a clean state. ```bash 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 ' ``` -------------------------------- ### Test dependency installation order variations Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/get_legacy.txt Validates that different sequences of 'go get' commands result in consistent dependency resolution for specific test repositories. ```bash env GOPATH=$WORK/tmp/d2 rm $GOPATH go get github.com/rsc/vgotest5 go get github.com/rsc/vgotest4 go get github.com/myitcv/vgo_example_compat rm $GOPATH go get github.com/rsc/vgotest4 go get github.com/rsc/vgotest5 go get github.com/myitcv/vgo_example_compat rm $GOPATH go get github.com/rsc/vgotest4 github.com/rsc/vgotest5 go get github.com/myitcv/vgo_example_compat rm $GOPATH go get github.com/rsc/vgotest5 github.com/rsc/vgotest4 go get github.com/myitcv/vgo_example_compat rm $GOPATH go get github.com/myitcv/vgo_example_compat go get github.com/rsc/vgotest5 github.com/rsc/vgotest4 rm $GOPATH go get github.com/myitcv/vgo_example_compat github.com/rsc/vgotest4 github.com/rsc/vgotest5 rm $GOPATH go get github.com/myitcv/vgo_example_compat github.com/rsc/vgotest5 github.com/rsc/vgotest4 rm $GOPATH go get github.com/rsc/vgotest4 github.com/myitcv/vgo_example_compat github.com/rsc/vgotest5 rm $GOPATH go get github.com/rsc/vgotest4 github.com/rsc/vgotest5 github.com/myitcv/vgo_example_compat rm $GOPATH go get github.com/rsc/vgotest5 github.com/myitcv/vgo_example_compat github.com/rsc/vgotest4 rm $GOPATH go get github.com/rsc/vgotest5 github.com/rsc/vgotest4 github.com/myitcv/vgo_example_compat ``` -------------------------------- ### Initialize libgccjit Context and Include Header Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/jit/docs/intro/tutorial03.md Standard setup for using libgccjit, including acquiring a context. ```c #include void test (void) { gcc_jit_context *ctxt; ctxt = gcc_jit_context_acquire (); ``` -------------------------------- ### Get Directory of a Module Path Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_list_std.txt Retrieves the file system directory for a given module path. This example shows that 'golang.org/x/net/http2/hpack' resolves to a path within the 'vendor' directory. ```bash go list -f '{{.Dir}}' golang.org/x/net/http2/hpack ``` -------------------------------- ### Go Source File Examples Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_tags.txt Various Go source files demonstrating build tag usage and package structure. ```go -- empty.go -- package m ``` ```go -- excluded.go -- // +build windows,mips package m import _ "example.com/version" ``` ```go -- tools.go -- // +build tools package tools import _ "rsc.io/quote" ``` ```go -- ignore.go -- // +build ignore package ignore import _ "example.com/doesnotexist" ``` -------------------------------- ### Disallow Git for Private Modules Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/govcs.txt Configure GOVCS to disallow Git for private modules. This example shows how to prevent `go get` from using Git for private repositories. ```bash env GOPRIVATE='github.com/google' ! go get github.com/google/go-cmp stderr '^go: GOVCS disallows using git for private github.com/google/go-cmp; see 'go help vcs'$' ``` -------------------------------- ### Go Module File Example Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_tidy_compat_irrelevant.txt A go.mod file for a module 'example.com/m' specifying Go 1.17 and a replace directive for a local module 'example.net/lazy'. ```go module example.com/m go 1.17 replace ( example.net/lazy v0.1.0 => ./lazy example.net/requireincompatible v0.1.0 => ./requireincompatible ) require example.net/lazy v0.1.0 ``` -------------------------------- ### Report Malformed GOVCS Entry Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/govcs.txt This example shows how an invalid GOVCS entry (missing colon) is reported when attempting to get a package. Ensure GOVCS entries are correctly formatted. ```bash env GOVCS='git' ! go get github.com/google/go-cmp stderr '^package github.com/google/go-cmp: malformed entry in GOVCS (missing colon): "git"$' ``` -------------------------------- ### Define main.go File Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_upgrade_pseudo.txt Example main.go file importing the test module. ```go package x import _ "example.com/pseudoupgrade" ``` -------------------------------- ### Allow Git by Default Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/govcs.txt Illustrates that Git is allowed by default for public repositories when GOVCS is not explicitly set. This example uses `go get` to fetch a module using Git. ```bash # git is OK by default env GOVCS= env GONOSUMDB='*' [net] [exec:git] [!short] go get rsc.io/sampler ``` -------------------------------- ### Example of Krunching `ada-strings-wide_fixed.adb` with Special Prefix Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst Demonstrates the krunching process for a system file starting with 'ada-', showing how the prefix is replaced and the name is subsequently shortened to eight characters. ```text ada-strings-wide_fixed 22 a- strings wide fixed 18 a- string wide fixed 17 a- strin wide fixed 16 a- stri wide fixed 15 a- stri wide fixe 14 a- str wide fixe 13 a- str wid fixe 12 a- str wid fix 11 a- st wid fix 10 a- st wi fix 9 a- st wi fi 8 Final file name: a-stwifi.adb ``` -------------------------------- ### Installing libgccjit Configurations Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/jit/docs/internals/index.md Install the --enable-host-shared configuration first, followed by the standard configuration. This ensures that the faster build of 'cc1' and other components overwrites the slower ones. ```bash # 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 ``` -------------------------------- ### Compile and Run Example Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/jit/docs/cp/intro/tutorial02.md This section provides the command-line instructions to compile the C++ example using g++ and link against libgccjit, followed by the command to execute the compiled program. ```console $ gcc \ tut02-square.cc \ -o tut02-square \ -lgccjit # Run the built program: $ ./tut02-square ``` -------------------------------- ### Document standard library package Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_nomod.txt Use `go doc` to get documentation for standard library packages. The `unsafe` package is shown as an example. This command may be prefixed with `[!gccgo]` in some contexts. ```bash [!gccgo] go doc unsafe ``` -------------------------------- ### Example go.mod File Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_get_ambiguous_pkg.txt A standard go.mod file configuration. ```text -- go.mod -- module test go 1.16 ``` -------------------------------- ### Go Test File for Vet Example Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/test_vet.txt A Go test file that calls a function F() which is expected to produce a vet error. This setup is used to test vet tool behavior. ```go package p2 import "testing" func TestF(t *testing.T) { F() } ``` -------------------------------- ### Go Module Configuration Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_retract_rename.txt Configuration file for the example module. ```go.mod module example.com/use go 1.16 require example.com/retract/rename v1.0.0-bad ``` -------------------------------- ### Ada Variant Record Size - Subprogram Parameter Example Source: https://github.com/autc04/retro68/blob/master/gcc/gcc/ada/doc/gnat_rm/representation_clauses_and_pragmas.rst Demonstrates how to get the size of the current variant of a record by passing it as a subprogram parameter. The 'Size attribute on the parameter returns the actual size of the current variant. ```ada with Text_IO; use Text_IO; procedure q is type R1 (A : Boolean := False) is record case A is when True => X : Character; when False => null; end case; end record; V2 : R1; function Size (V : R1) return Integer is begin return V'Size; end Size; begin Put_Line (Integer'Image (V2'Size)); Put_Line (Integer'Image (Size (V2))); V2 := (True, 'x'); Put_Line (Integer'Image (V2'Size)); Put_Line (Integer'Image (Size (V2))); end q; ``` -------------------------------- ### Test Fuzzing Environment Variable Setting Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/test_fuzz_setenv.txt This Go code tests setting and getting environment variables within a fuzz test. It ensures that the environment variable is correctly set by `f.Setenv` and not present before the fuzzing worker starts. ```go package fuzz import ( "flag" "os" "testing" ) func FuzzA(f *testing.F) { if s := os.Getenv("TEST_FUZZ_SETENV_A"); isWorker() && s == "" { f.Fatal("environment variable not set") } else if !isWorker() && s != "" { f.Fatal("environment variable already set") } f.Setenv("TEST_FUZZ_SETENV_A", "A") if os.Getenv("TEST_FUZZ_SETENV_A") == "" { f.Fatal("Setenv did not set environment variable") } f.Fuzz(func(*testing.T, []byte) {}) } func FuzzB(f *testing.F) { if os.Getenv("TEST_FUZZ_SETENV_A") != "" { f.Fatal("environment variable not cleared after FuzzA") } f.Skip() } func isWorker() bool { f := flag.Lookup("test.fuzzworker") if f == nil { return false } get, ok := f.Value.(flag.Getter) if !ok { return false } return get.Get() == interface{}(true) } ``` -------------------------------- ### Module A/x Package Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/mod_lazy_new_import.txt Package 'x' within module 'a', which has a direct import of 'example.com/b'. ```go package x import _ "example.com/b" ``` -------------------------------- ### List Packages with Wildcard Pattern Source: https://github.com/autc04/retro68/blob/master/gcc/libgo/go/cmd/go/testdata/script/list_std.txt This example shows how 'go list' handles wildcard patterns, specifically with 'cmd/...'. It confirms that 'cmd/compile' is listed, but 'cmd/vendor' is not, illustrating how vendored packages are excluded from wildcard matches starting with 'cmd'. ```bash go list cmd/... ``` ```bash stdout cmd/compile ``` ```bash ! stdout cmd/vendor ```